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