I'm very new to both ASP and ASP.Net. I'm working to convert an old ASP page to ASP.Net using VB. My code looks something like this:
I'm getting an OleDBException on line 24 reading "Syntax error or access violation."
If I manually execute the stored procedure, it works and returns the correct records.
If I remove line 23, it runs, but objReader.RecordsAffected is set to -1, and it behaves as if no records were returned.
Any ideas what I'm doing wrong? I appreciate any assistance.
Code:
1 <%@ Page Language="VB" Debug = True%>
2 <%@ Import Namespace="System.Data" %>
3 <%@ Import Namespace="System.Data.OleDb" %>
4
5 <%
6 Response.Buffer = True
7 %>
8 <script runat="server">
9 dim login as string
10 dim password as string
11 dim connstr as string
12 dim conn as OleDbConnection
13 dim objCommand as OleDbCommand
14 dim objReader as OleDbDataReader
15
16 sub Page_Load(Sender as Object, e as EventArgs)
17 login = Session("login")
18 password = Session("password")
19 Response.Clear
20 connstr = "Provider=SQLOLEDB;Initial Catalog=MyDataBase;UID=" & login & ";Pwd=" & password & ";"
21 conn = new OleDbConnection(connstr)
22 objCommand = new OleDbCommand("MyStoredProc 'x', 1", conn)
23 objCommand.CommandType = CommandType.StoredProcedure
24 objReader = objCommand.ExecuteReader
...
I'm getting an OleDBException on line 24 reading "Syntax error or access violation."
If I manually execute the stored procedure, it works and returns the correct records.
If I remove line 23, it runs, but objReader.RecordsAffected is set to -1, and it behaves as if no records were returned.
Any ideas what I'm doing wrong? I appreciate any assistance.