Executing a StoredProcedure using ADOCommand object in ASP.NET 2.0



Hi,
I'm not sure if this is the right group to post this or not but I will
give it a try :(
I'm trying to convert an ASP application into ASP.NET 2.0 (changing the
extension for files .asp to .aspx and then fixing all the issues). While
fixing one of the page I found that the old page calls a stored procedure and
gets the data and this was done using ServerSide Java Script.
Now since this page has been changed to ASPX page 2.0 with the page
directive as <%@ Page Language="VB" %> I cannot use Server Side JavaScript
and VB Script on one page. So I decided to move the code to a class file. The
code looks something like this..
public static ADODB.Recordset GetDataAsADORecordSet_SP(string strSPName,
string strProductID, string strConn)
{
OleDbDataAdapter custDA = new OleDbDataAdapter();
ADODB.Connection adoConn = new ADODB.Connection();
ADODB.Recordset adoRS = new ADODB.Recordset();
ADODB.Command adoCommand = new ADODB.Command();
adoConn.Open(strConn, "", "", -1);
adoCommand.ActiveConnection = adoConn;
adoCommand.CommandType = CommandTypeEnum.adCmdStoredProc ;
adoCommand.CommandText = strSPName;


adoCommand.Parameters.Append(adoCommand.CreateParameter("product_id",
DataTypeEnum.adInteger, ParameterDirectionEnum.adParamInput,32 ,
Convert.ToInt32 (strProductID)));
object recordsAffected = 0;
object parameters;
parameters = new string[] {};

adoRS = adoCommand.Execute(out recordsAffected, ref parameters,
(int)ExecuteOptionEnum.adExecuteNoRecords );


int count = adoRS.RecordCount;

return adoRS;
}
Now when I call this function form the .aspx page it gives me an error on
line adoRS = adoCommand.Execute(out recordsAffected, ref parameters,
(int)ExecuteOptionEnum.adExecuteNoRecords ); the error that I get is
"[Microsoft][ODBC SQL Server Driver]Syntax error or access violation". Can
anyone point what’s wrong with this code and if there is another way to
execute the StoredProcedure.

I only want the data to come back as a RecordSet so that I've to change
minimum when I display the data on the page.

Any suggestions or pointer would be greatly appreciated.

Thanks in advance
MJ

.



Relevant Pages

  • Re: Pass recordset from code-behind to aspx file
    ... Now I can't draw the control for the Pivottable on the aspx page. ... or some way to pass the record set over to the aspx file so I can ... I have established an adodb recordset in my code-behind, ...
    (microsoft.public.dotnet.framework.aspnet)
  • ADO recordset to Datagridview of VB 2005
    ... I have installed Visual Studio 2005 and am working on Visual ... I have created a ADODB connection to a DB2 database in a server ... Dim Adors as ADODB.Recordset ... Before Assigning the Recordset ...
    (microsoft.public.vb.database.ado)
  • RE: Problem with returning a recordset from a VBA function
    ... Access report by doing the following: ... Within this function I decalre an internal adoRs object that calls the ... stored procedure and then do Set GetPhysicianData = adoRS. ... recordset is closed. ...
    (microsoft.public.access.modulesdaovba)
  • Use a recordset inside a Function?
    ... I'm trying to use a recordset inside of a function but I'm getting an "object required 'adoRS" error. ... Set adoCN = server.CreateObject ... function GetRecords() ...
    (microsoft.public.inetserver.asp.general)
  • RE: Problem with returning a recordset from a VBA function
    ... If you need to set the report's recordset, ... "Dave" wrote: ... Access report by doing the following: ... Within this function I decalre an internal adoRs object that calls the ...
    (microsoft.public.access.modulesdaovba)