📄 untexcsql.pas
字号:
unit UntExcSQL;
interface
uses
Windows, UntDataClass,UntDMAppMDI,ADODB, DB;
type
TExcSQL = class(TDataClass)
protected
private
procedure AddDelModData(SQL : string);
procedure SearchData(SQL : string);
public
procedure ExcSQL(SQL : string;ExcType : string);
constructor Create();
destructor destroy;override;
end;
implementation
procedure TExcSQL.AddDelModData(SQL : string);
begin
try
ADOQuery.Close;
ADOQuery.SQL.Clear;
ADOQuery.SQL.Add(SQL);
ADOQuery.ExecSQL;
except
MessageBox(0,'执行更新数据失败,请检查!','系统提示',MB_OK+MB_ICONINFORMATION);
end;
end;
constructor TExcSQL.Create;
begin
ADOQuery := TADOQuery.Create(nil);
DataSource := TDataSource.Create(nil);
self.ADOQuery.Connection :=DM.ADOConnection;
self.DataSource.DataSet := self.ADOQuery;
end;
destructor TExcSQL.destroy;
begin
self.ADOQuery.Free;
self.DataSource.Free;
inherited;
end;
procedure TExcSQL.ExcSQL(SQL, ExcType: string);
begin
if ExcType='Search' then
self.SearchData(SQL)
else if (ExcType='Add') or (ExcType='Mod') or (ExcType='Del') then
self.AddDelModData(SQL)
else
MessageBox(0,'执行SQL语句失败,请检查!','系统提示',MB_OK+MB_ICONINFORMATION);
end;
procedure TExcSQL.SearchData(SQL: string);
begin
try
ADOQuery.Close;
ADOQuery.SQL.Clear;
ADOQuery.SQL.Add(SQL);
ADOQuery.active:=True;
except
MessageBox(0,'执行SQL查询操作失败,请检查!','系统提示',MB_OK+MB_ICONINFORMATION);
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -