Link to home
Start Free TrialLog in
Avatar of jnearing
jnearing

asked on

MSSQL DB-Library calls running stored procedure

I'm running Microsoft SQL Server 6.5 and using VC++ 5.0

I have a SQL Server stored procedure that has no input or
output parameters, but returns a value from executing a query.  There are two variables inside the procedure that basically retrieve a value from a table and increment it by one, updates the table and returns the new value.

I am executing the stored procedure using DB-Library commands like this.
retcode = dbrpcinit(dbproc,"get_shipment_num",0);
if (retcode==SUCCEED)
{
   retcode = dbrpcsend(dbproc);
   retcode = dbsqlok(dbproc);

The call to dbsqlok fails, which indicates I probably have a syntax error.  It doesn't seem like I should need any dbrpcparam calls, since I have no parameters, but I have tried that way also.  No success yet.

I'd be really happy to hear from someone that has done this before and can tell me how to make it work.

thanks


Avatar of fdsnet
fdsnet

Well, the first issue is always permissions. Make sure the permissions set on the stored procedure (via either the script or SQL Enterprise) are correct for the userid and password you are using.
Avatar of jnearing

ASKER

Permissions are OK.   Public has execute permissions on the stored procedure, and we are using it successfully in several Visual Basic forms.    As this program will run as a scheduled task under SQL Executive, I am using the system adminitrator account, who owns the stored procedure.
I'm pretty sure I'm missing something in the DB-Library call that invokes the stored procedure.

thanks
ASKER CERTIFIED SOLUTION
Avatar of fdsnet
fdsnet

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks, I didn't know about dbfcmd.  That will come in handy.

There's some bad pizza somewhere that I will have to figure out.
I recoded it to use a dbcmd to select from my table and dbfcmd to update a value.   The dbcmd failed, then just for fun I moved that bit of code up to the beginning of the program and it worked.   The call to the stored procedure also worked when placed at the beginning.

I wouldn't mind seeing a bit of code if you could send something.   This DB-Library stuff is new to me and there doesn't seem to be much information on it.

thanks

Jim