Connecting Tech Pros Worldwide Forums | Help | Site Map

ADO Stored procedure not working using C#

TedL
Guest
 
Posts: n/a
#1: Nov 15 '05
Can anyone find anything wrong with this code? I don't get any
exceptions from it, but I don't get any data returned either! Any
help would be greatly appreciated--I've been working on this all
friggin' day! Thanks!

Ted
****************************

ADODB.Connection adoConn2 = new ADODB.ConnectionClass();
ADODB.Recordset adoRS = new ADODB.RecordsetClass();
ADODB.Command cmd = new ADODB.CommandClass();
ADODB.Parameter param = new ADODB.ParameterClass();

adoConn2.Open("PROVIDER=SQLOLEDB;INITIAL
CATALOG=pubs;SERVER=localhost;", "sa", "password", -1);

cmd.CommandText = "byroyalty";
cmd.CommandType = ADODB.CommandTypeEnum.adCmdStoredProc;
param = cmd.CreateParameter("percentage",
ADODB.DataTypeEnum.adInteger,
ADODB.ParameterDirectionEnum.adParamInput, 0, 100);
cmd.Parameters.Append(param);

object objRecs, objParameters = cmd.Parameters;

cmd.ActiveConnection = adoConn2;
adoRS = cmd.Execute(out objRecs, ref
objParameters,(int)ADODB.CommandTypeEnum.adCmdStor edProc);

******************************************

Chris Torgerson
Guest
 
Posts: n/a
#2: Nov 15 '05

re: ADO Stored procedure not working using C#


Nothing immediately jumping out, but my question woul be what does the sp
look like, if it hasn't been modified from the default sql installation you
are probably running into a problem with the rowcount. ADO has real
problems with this via OLEDB. Simply add SET NOCOUNT ON after the AS in the
sp.

Just as another question, is there a particular reason you are not using the
ADO.NET classes??

hth
Chris Torgerson
"TedL" <tlevieux@hotmail.com> wrote in message
news:f8bc153f.0403021518.3f1e8a19@posting.google.c om...[color=blue]
> Can anyone find anything wrong with this code? I don't get any
> exceptions from it, but I don't get any data returned either! Any
> help would be greatly appreciated--I've been working on this all
> friggin' day! Thanks!
>
> Ted
> ****************************
>
> ADODB.Connection adoConn2 = new ADODB.ConnectionClass();
> ADODB.Recordset adoRS = new ADODB.RecordsetClass();
> ADODB.Command cmd = new ADODB.CommandClass();
> ADODB.Parameter param = new ADODB.ParameterClass();
>
> adoConn2.Open("PROVIDER=SQLOLEDB;INITIAL
> CATALOG=pubs;SERVER=localhost;", "sa", "password", -1);
>
> cmd.CommandText = "byroyalty";
> cmd.CommandType = ADODB.CommandTypeEnum.adCmdStoredProc;
> param = cmd.CreateParameter("percentage",
> ADODB.DataTypeEnum.adInteger,
> ADODB.ParameterDirectionEnum.adParamInput, 0, 100);
> cmd.Parameters.Append(param);
>
> object objRecs, objParameters = cmd.Parameters;
>
> cmd.ActiveConnection = adoConn2;
> adoRS = cmd.Execute(out objRecs, ref
> objParameters,(int)ADODB.CommandTypeEnum.adCmdStor edProc);
>
> ******************************************[/color]


Closed Thread