Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

MSSQL DB-Library calls running stored procedure

Posted on 1998-09-09
4
Medium Priority
?
446 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 800 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This is a short and sweet, but (hopefully) to the point article. There seems to be some fundamental misunderstanding about the function prototype for the "main" function in C and C++, more specifically what type this function should return. I see so…
Examines three attack vectors, specifically, the different types of malware used in malicious attacks, web application attacks, and finally, network based attacks.  Concludes by examining the means of securing and protecting critical systems and inf…
The goal of this video is to provide viewers with basic examples to understand recursion in the C programming language.
The goal of this video is to provide viewers with basic examples to understand opening and reading files in the C programming language.
Suggested Courses

824 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