我想實現這樣的功能:在Sql Server中如何寫一個存儲過程由Delphi調用,每執行一段程序,我就報告一個信息到前台delphi顯示出來,但不終止存儲過程繼續往下執行.
如:Delete from Table1
提示信息到前台Delphi:"已刪除了Table1表"
Delete from Table2
提示信息到前台Delphi:"已刪除了Table2表"
Insert into Table3 (Code) values('ddd')
提示信息到前台Delphi:"已插入了一條記錄到Table3表中"
..........請指點.
如:Delete from Table1
提示信息到前台Delphi:"已刪除了Table1表"
Delete from Table2
提示信息到前台Delphi:"已刪除了Table2表"
Insert into Table3 (Code) values('ddd')
提示信息到前台Delphi:"已插入了一條記錄到Table3表中"
..........請指點.
showmessage('提示信息到前台Delphi:"已刪除了Table2表"')
不行吗?
有问题请发信息到我的E-mail:[email protected]
分成三個存儲過程,具體怎樣作,能指點一下嗎?謝!
Delete from Table1
RAISERROR ('已刪除了Table1表', 16, 1)
Delete from Table2
RAISERROR ('已刪除了Table2表',16,1)
Insert into Table3 (Code) values('ddd')
RAISERROR ('已插入了一條記錄到Table3表中')GOdelphi:unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, DB, ADODB, StdCtrls, AppEvnts;type
TForm1 = class(TForm)
Button1: TButton;
ad: TADOStoredProc;
ApplicationEvents1: TApplicationEvents;
procedure Button1Click(Sender: TObject);
procedure ApplicationEvents1Exception(Sender: TObject; E: Exception);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
begin ad.ExecProc;
end;procedure TForm1.ApplicationEvents1Exception(Sender: TObject;
E: Exception);
begin
ShowMessage(e.Message);
end;///调试状态出错
/// 生成主程序后 直接运行 .exeend.
但Raiserror提示信息的時候已經終止了存儲過程的執行了.有沒有
其他的方法呢?請您指點.Thanks in advance.
试试就知道
顯然Raiserror反映的信息,需要用戶在前台作出響應才行!看來這個方法
不是很好尋!
也不需要 前台做出反应
当你得到 信息时即 procedure TForm1.ApplicationEvents1Exception(Sender: TObject;
E: Exception);
begin
// ShowMessage(e.Message);
memo1.lines.add(e.Message);
Exit ;
end;
你测试过这段程序吗??????你用过 Delphi 程序错误处理吗?????试试就知道 !!!还需要讲 什么 ???
Delete from Table1
RAISERROR ('已刪除了Table1表', 16, 1)
Delete from Table2
RAISERROR ('已刪除了Table2表',16,1)
Insert into Table3 (Code) values('ddd')
RAISERROR ('已插入了一條記錄到Table3表中',16,1)GOdelphi:unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, DB, ADODB, StdCtrls, AppEvnts;type
TForm1 = class(TForm)
Button1: TButton;
ad: TADOStoredProc;
ApplicationEvents1: TApplicationEvents;
Memo1: TMemo;
procedure Button1Click(Sender: TObject);
procedure ApplicationEvents1Exception(Sender: TObject; E: Exception);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
begin
ad.ProcedureName :='aa;1';
ad.ExecProc;
end;procedure TForm1.ApplicationEvents1Exception(Sender: TObject;
E: Exception);
begin
//ShowMessage(e.Message); memo1.lines.add(e.Message);
Exit ;
end;///调试状态出错
/// 生成主程序后 直接运行 .exeend.