Solved

Using TQuery, get Return code from SQL Server

Posted on 2000-02-29
4
436 Views
Last Modified: 2010-04-04
I'm using Delphi 4.0 and SQL Server 7.0.  The problem is I don't know how to get the return code returned by a stored procedure from SQL Server, using TQuery.

0
Comment
Question by:yurrea
  • 2
4 Comments
 

Expert Comment

by:ellessar
ID: 2571688
As far as I know, you need to use the TStoredproc object for all stored procedure calls. The return value is stored in the params of the object.

Assuming that you have not tried this: If you want to you can try and do an execsql - using a TQuery - and check the return value, but never having done this, I cannot place any faith in whether this will work...
0
 

Author Comment

by:yurrea
ID: 2571754
ellesar:

I'm using TQuery for scalability.  One of the experts told me that for TQuery is more flexible that TStoredProc.  In using TQuery, I use 'open' to get values from my query, and 'execsql' whenever I don't need any feedback from sql server.  However, I'm wondering if I can get the return code from a stored procedure through TQuery.
0
 

Expert Comment

by:ellessar
ID: 2572096
As far as I know, you need to use the TStoredproc object for all stored procedure calls. The return value is stored in the params of the object.

Assuming that you have not tried this: If you want to you can try and do an execsql - using a TQuery - and check the return value, but never having done this, I cannot place any faith in whether this will work...
0
 

Accepted Solution

by:
nitdgrev earned 100 total points
ID: 2599454
Do you require a live datset in your app or is it a readonly result set ?

With TStoredProc's you can return results to Delphi by using the TStoredProc.Open call and when you only want to execute a set of command you use TStoredProc.ExecProc.  The ExecProc enables you to access the return value of the procedure.

Note, in using a Tstoredproc to return a result set you must have the corresponding SELECT statement in the stored procedure.  This has got to be preferable in cases where a Non-Editable resultset is required (for example reporting) because if changes are required they can be done on the server side.  

In the documentation it says that cached updates can be used with TStoredProc's but as yet I haven't tried so I don't know if this is true or not.
0

Featured Post

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

685 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