Thursday, March 29, 2012

calling stored procedure in VC++

i have a stored procedure to get the user pin.
the stored procedure works perfectly as i tested it both in VB and ASP,
but when i try to call stored procedure from VC++, then i get a
Idispatch error #3092.
here is the code:

BSTR newpin;
_bstr_t qsql = "{call user.getpin(?,{resultset 100,pin})}";
command->PutActiveConnection(conn);
command->PutCommandText(qsql);
command->Parameters->Refresh();
command->Parameters->Item[_variant_t((short)0)]->Value = userid;
rst = command->Execute(NULL,NULL,adCmdText);
if(rst->RecordCount > 0)
{
newpin = rst->Fields->GetItem((short)0)->GetValue();

}

is there any problem with this code.
thanks
Can you provide more complete sample including code for creating stored procedure? Are you sure about syntax "{call user.getpin(?,{resultset 100,pin})}";? Also which line of code throws the exception? BWT RecordCount may be 0 but

rst->Fields->GetItem((short)0)->GetValue();

may still return correct value. Also have you tried PutRefActiveConnection instead? It's difficult to say without more information.

No comments:

Post a Comment