Solved

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

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

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…
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…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Suggested Courses
Course of the Month9 days, 19 hours left to enroll

624 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