Solved

MSSQL DB-Library calls running stored procedure

Posted on 1998-09-09
4
432 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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Suggested Solutions

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…
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…
The goal of this video is to provide viewers with basic examples to understand how to create, access, and change arrays in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use switch statements in the C programming language.

757 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

22 Experts available now in Live!

Get 1:1 Help Now