Delphi calls sql-server2000 Stored Procedure

Source: Internet
Author: User
How does delphi call SQL stored procedures and obtain results?
Adostoredproc1.close;
Adostoredproc1.procedurename: = 'SP _ thl ';
Adostoredproc1.parameters. Clear;
Adostoredproc1.parameters. createparameter ('out', ftinteger, pdoutput, 1, 1 );
Adostoredproc1.execproc;
Edit1.text: = adostoredproc1.parameters [0]. value;

Leftstr (), the Run Command System actually told me "Unrecognized identifier leftstr"

Add the strutils Unit

Simplest Stored Procedure
Database End
Create procedure aaa
@ WWW varchar (10) // Parameter
As
Select * from employees where pusercode = @ WWW
Go

Frontend Stored Procedure
Procedure tform1.button1click (Sender: tobject );
VaR outcount: integer;
Begin

Adostoredproc1.parameters. parambyname ('@ WWW'). Value: = '123 ';
Adostoredproc1.open;
// Adostoredproc1.execproc ;//
{Suppose you already have a stored procedure on the SQL server,
Then you and the program need an adoconnection to set the database connection,
Adostoredproc
After connection is connected to adoconnection
Producedure automatically displays the existing stored procedures in the database.

After the connection is set, you can see all the callable stored procedures in procedurename of adostoredproc.
, Select the storage process to use (according to the parameters, you can see the required parameters)
Program call code:
With adostoreproc1 do
Begin
Adostoredproc1.parameters. parambyname (''). Value: =;
Adostoredproc1.execproc;
End;
In the above example, no result set is returned during the storage process,
If a returned result set exists, open it using adostoredproc1.open}

// Showmessage (inttostr (adostoredproc1.parameters. parambyname ('@ outcount'). Value ));
End;

Stored Procedure with output parameters

Create procedure aaa
@ ABC char (10 ),
@ Mycount int output
As
Select @ mycount = count (*) from employees where pusercode = @ ABC
Return
Go

How to extract Parameters
Procedure tfrm_worker_info.button1click (Sender: tobject );
VaR outcount: integer;
Begin

Adostoredproc1.parameters. parambyname ('@ abc'). Value: = '123 ';
Adostoredproc1.execproc;
Showmessage (inttostr (adostoredproc1.parameters. parambyname ('@ mycount'). Value ));
End;

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.