Solved

Sample Code - Delphi, ADO, Stored Procedures

Posted on 2003-11-26
1
1,039 Views
Last Modified: 2010-04-05
Hi,

is there anyone who can give me sample code, for using a stored procedure in Mssql, taking a parameter, using ADO??

cheers,

henrik
0
Comment
Question by:henrikatwork
[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
1 Comment
 
LVL 3

Accepted Solution

by:
ThoseBug earned 500 total points
ID: 9824990
you can work with stored procedure like a ADOquery ..this is an simple sample...
SQL Table Users
                   id_users int
                   name varchar(50)

and this is a Stored Procedure sample
 
CREATE PROCEDURE test @name varchar(20)
 AS
select * from users where name like @name
GO

now in Delphi...add a ADOStoredProc (if you don't have an ADOconection then build  a connection string to your MS SQLserver )
in the property ProcedureName find the procedure name (in our sample test)
then in ADOStoredProc Parameters you can see the parameters (in our case @name) (it the parameter type is not asignes you can define that in our case FtString)
now to test it we are getting a button to do this..

procedure TForm1.Button1Click(Sender: TObject);
begin
ADOStoredProc1.Parameters.ParamByName('@name').value := '%some_name%';
ADOStoredProc1.ExecProc;

that's all...if you wanna see the results into dbgrid you can atach an datasource to your storedprocedure and may be you need adostoredProc1.Open;
hope this help you...

0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

751 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