Solved

Sample Code - Delphi, ADO, Stored Procedures

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

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…
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…

756 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