Beginner delphi and SQL Server stored procedures

Source: Internet
Author: User

As usual, first on the Delphi Interface Control layout:

1 adoconnection, 1 adoquery, 1 DataSource, 1 button, 1 Dbgrideh (optional)

Pre-Preparation: 1, set adoconnection connectionstring, for convenience: Provider=SQLOLEDB.1; password= database login password; Persist Security info=true; User id= Database login name; Data source= database server address, setting loginprompt set to False

2, Adoquery connection point to ADOConnection

3, DataSource dataset pointing to Adoquery

Begin:

1. Open SQL Server 2008, select Database-Right-click New query:

 --New stored procedure 
1 create proc Selectaddr
2 as 3 begin 4 select * from MTable5 end
 alter  proc   SELECTADDR 
--Add an entry parameter 2 " Span style= "color: #008000;" > @addr varchar (50 ) 3 4 begin 5 select * from Mtable t where t.addr @addr 6 end

Click on execute to be able to database-programmability-stored procedure see the new selectaddr this stored procedure

2. Double click button on Delphi design interface.

1 procedureTform4.button1click (sender:tobject);2 var3Ssqltext:string;4 begin5Ssqltext: = Format ('exec selectaddr%s',['3606163310030817']);6 ADOQuery1.SQL.Clear;7 ADOQuery1.SQL.Add (ssqltext);8 Adoquery1.open;9 End;

Compile, as a result, query out a record of addr:

Beginner delphi and SQL Server stored procedures

Related Article

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.