📄 unit1.pas
字号:
(*
使用前请先建立资料库别名TestMDB,并指向Test.mdb(内含Customer,Employee资料表)
*)
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons, DB, ADODB, Grids, DBGrids;
type
TForm1 = class(TForm)
DataSource1: TDataSource;
DBGrid1: TDBGrid;
ADOConnection1: TADOConnection;
ADOTable1: TADOTable;
BitBtn1: TBitBtn;
ADOTable2: TADOTable;
procedure BitBtn1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.BitBtn1Click(Sender: TObject);
var
sltmp1: TStrings;
i,j: Integer;
begin
sltmp1 := TStringList.Create;
try
//删除全部记录
ADOTable2.Close;
ADOTable2.Open;
ADOTable2.First;
for i:=0 to ADOTable2.RecordCount-1 do
begin
ADOTable2.Delete;
ADOTable2.Next;
end;
//取得所有TableName,并记录到sltmp1(sltmp1会先被自动清空)
ADOConnection1.GetTableNames(sltmp1, False);
for i := 0 to (sltmp1.Count - 1) do
begin
ADOTable2.Insert;
ADOTable2.FieldByName('TableName').AsString := sltmp1[i];
if ADOTable1.Active then
ADOTable1.Close;
ADOTable1.TableName := sltmp1[i];
ADOTable1.Open;
ADOTable2.FieldByName('RecordCount').AsInteger := ADOTable1.RecordCount;
ADOTable2.Post;
end;
finally
sltmp1.Free;
ADOTable1.Close;
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -