Solved

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

Posted on 2002-07-28
2
284 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
creating threads in delphi 1 189
Firemonkey DbLookupComboBox equivalent ? 2 76
Twebbrowser add css to the header 3 49
Delphi: sending SMS on android platform 1 94
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…
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…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

740 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