untexcsql.pas

来自「里面有EXE文件,直接运行就可以,密码也在说明文件里,如有需要可做相应的改变」· PAS 代码 · 共 70 行

PAS
70
字号
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 + =
减小字号Ctrl + -
显示快捷键?