ADO Stored procedure not working using C#

T

TedL

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.adCmdStoredProc);

******************************************
 
C

Chris Torgerson

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top