Solved

Sample Code - Delphi, ADO, Stored Procedures

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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

746 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now