?? 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 + -