Solved

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

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Need Delphi function to get Youtube video title 5 222
Simple Delphi Question 9 83
delphi parse string to params 3 97
How to renew a Delphi rad-studio licence? 5 49
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.
This is a video that shows how the OnPage alerts system integrates into ConnectWise, how a trigger is set, how a page is sent via the trigger, and how the SENT, DELIVERED, READ & REPLIED receipts get entered into the internal tab of the ConnectWise …

929 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

9 Experts available now in Live!

Get 1:1 Help Now