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

x
?
Solved

How to get value return when using strore procedure, ADO component

Posted on 2002-07-28
2
Medium Priority
?
291 Views
Last Modified: 2010-04-04
Dear Advisor !

I use Delphi 5.0 + SQL Server 7.0, ADO Component

I want to send a command to SQL, so i write a sqlstatement in window :
ADOCommandText := exec sp_password 'aaa', 'bbb', 'ccc'

It runs well. But i want to get the value return when calling a store procedure. In this case, I do not want to trap the error to know the know the value. i want to know how to call a store procedure in D5

Thank for all consider
0
Comment
Question by:NamCit
2 Comments
 
LVL 3

Accepted Solution

by:
rondi earned 60 total points
ID: 7184667
You might wanna use the TADOCommand component. All you need
to do is set some of its properties such as the name of
the stored procedure as well the parameters to be passed to
the stored procedure.

The parameters are contained in a list of TParameter
objects. Each TParameter simply has a name and a value.
Once the stored procedure has been executed, the return
code is stored in Parameter number 0.
i.e ReturnCode := MyADOCommand.Parameters[0].Value;

If you like, i'll post a cool unit that I wrote to let
me call stored procedures really easily.
Whenever I'm workin with a new database, I just write a descendant class from the unit and add stored procedure
wrappers as I need them.

rondi
0
 

Author Comment

by:NamCit
ID: 7184846

My code :

     s := 'exec sp_password ' + QuotedSTr('a') + ', ' + QuotedSTr('a') + ', ' + QuotedSTr('aaa') ;
     HopDongForm.ADOCommand.CommandText := s ;
     HopDongForm.ADOCommand.Execute ;

 t := HopDongForm.ADOCommand.Parameters[0].Value
   

The errorat the lastest line :

'List indext out of bounds (0)'

If i run that sqlstatemnet in SQL Query of SQL Server. It is Ok.

Please correct my code for me


0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
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…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

963 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