Solved

Sample Code - Delphi, ADO, Stored Procedures

Posted on 2003-11-26
1
1,031 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
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

ScreenConnect 6.0 Free Trial

Discover new time-saving features in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

Question has a verified solution.

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

Suggested Solutions

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
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…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
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…

832 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