Solved

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

Posted on 2002-07-28
2
277 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 20 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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This video discusses moving either the default database or any database to a new volume.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

760 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

21 Experts available now in Live!

Get 1:1 Help Now