?? execsqlclass.pas
字號:
unit Execsqlclass;
interface
uses
sysutils,ADODB;
type
TexecsqlEvent=procedure(sender:Tobject;Qty:Tadoquery) of object;
type
Texecsql=class
private
Fadoconnection:Tadoconnection;
Fadoquery:Tadoquery;
Fcons:String;
Fsql:String;
FexecsqlException:Exception;
FexecsqlEvent:TexecsqlEvent;
protected
procedure ExecsqlError;
public
procedure Execute;
constructor Create(Fadoc:Tadoconnection;
fadoq:Tadoquery;
fconstring:string;
tmpsql:string);virtual;
destructor destroy();override;
property ExecsqlEvent:TexecsqlEvent read FexecsqlEvent write FexecsqlEvent;
end;
implementation
{ Texecsql }
constructor Texecsql.Create(Fadoc: Tadoconnection; fadoq: Tadoquery;
fconstring, tmpsql: string);
begin
Fadoconnection:=Fadoc;
Fadoquery:=Fadoq;
Fcons:=Fconstring;
Fsql:=tmpsql;
end;
destructor Texecsql.destroy;
begin
{do nothing};
inherited;
end;
procedure Texecsql.ExecsqlError;
begin
Abort;
end;
procedure Texecsql.Execute;
begin
try
fadoquery.Close;
fadoquery.SQL.Clear;
fadoquery.SQL.Add(' Begin transaction ');
fadoquery.SQL.Add(fsql);
fadoquery.SQL.Add(' commit transaction ');
fadoquery.ExecSQL;
if assigned(FexecsqlEvent) then
begin
FexecSqlEvent(self,Fadoquery);
end;
except
Fadoquery.Close;
Fadoquery.SQL.Clear;
Fadoquery.SQL.Add(' Rollback transaction ');
Fadoquery.ExecSQL;
FexecsqlException:=Exceptobject as Exception;
Execsqlerror;
end;
end;
end.
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -