Solved

MSSQL DB-Library calls running stored procedure

Posted on 1998-09-09
4
435 Views
Last Modified: 2008-02-26
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


0
Comment
Question by:jnearing
  • 2
  • 2
4 Comments
 

Expert Comment

by:fdsnet
ID: 1252607
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.
0
 
LVL 1

Author Comment

by:jnearing
ID: 1252608
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
0
 

Accepted Solution

by:
fdsnet earned 200 total points
ID: 1252609
what not simply use:

dbopen(...);
dbfcmd(...);
dbsqlexec(...);
dbresults(...);
while (dbnextrow(...) != no more rows);
dbclose(...);

are you familiar with these calls in general? i can send a code snippet if you like.

0
 
LVL 1

Author Comment

by:jnearing
ID: 1252610
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
 
0

Featured Post

Superior storage. Superior surveillance.

WD Purple drives are built for 24/7, always-on, high-definition security systems. With support for up to 8 hard drives and 32 cameras, WD Purple drives are optimized for surveillance.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode (http://en.wikipedia.org/wiki/Unicode)? They will have you believe that Unicode requires you to use…
The goal of this video is to provide viewers with basic examples to understand how to use strings and some functions related to them in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now