前言
經常有很多初學者問到在delphi中如何調用SQL Server的存儲過程?問題其實很好解決
首先
use pubs
if exists (select * from dbo
drop table [dbo]
GO
CREATE TABLE [dbo]
[id] [char] (
[name] [char] (
[descrip] [char] (
) ON [PRIMARY]
GO
然後
CREATE PROCEDURE myInsert
@id char(
@name varchar(
@descrip varchar(
AS
begin
insert into test (id
if @@rowcount=
begin
raiserror(
rollback transaction
end
end
GO
接下來
一個ADOConnection
(LoginPrompt:=false;
connectionstring:=Provider=SQLOLEDB
一個ADOStoredProc
(connection:=adoconnection
procedurename:=myinsert;//上面我們創建的那個)
一個ADOTable
(connection:=adoconnection
tablename:=test; //上面我們創建的那個)
一個Datasource
(dataset:=Tadotable;)
一個 DBGrid
(datasource:=datasource
一個Button
with adoStoredproc
begin
Parameters
parameters
parameters
ExecProc;
end;
Adotable
adotable
From:http://tw.wingwit.com/Article/program/SQLServer/201311/21984.html