Solved

MSSQL DB-Library calls running stored procedure

Posted on 1998-09-09
4
440 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

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

Preface I don't like visual development tools that are supposed to write a program for me. Even if it is Xcode and I can use Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small…
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 and use pointers in the C programming language.
The goal of this video is to provide viewers with basic examples to understand opening and writing to files in the C programming language.

752 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