Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Sample Code - Delphi, ADO, Stored Procedures

Posted on 2003-11-26
1
Medium Priority
?
1,060 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 1000 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

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…
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…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses

824 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