📄 unit1.pas
字号:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, DB, ADODB, Grids, DBGrids, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Label1: TLabel;
Label2: TLabel;
Edit1: TEdit;
ListBox1: TListBox;
DataSource1: TDataSource;
DBGrid1: TDBGrid;
ADOConnection1: TADOConnection;
ADOTable1: TADOTable;
OpenDialog1: TOpenDialog;
procedure Button1Click(Sender: TObject);
procedure ListBox1DblClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
myaccess:string;
const
mystr1='Provider=%s;Data Provider=%s;Data Source=%s';
myprovider='Msdatashape.1';
mydataprovider='Microsoft.Jet.OLEDB.4.0';
begin
opendialog1.filename:='*.mdb';
if opendialog1.execute then
begin
myaccess:=opendialog1.filename;
Edit1.text:=myaccess;
ADOConnection1.connected:=false;
ADOConnection1.ConnectionString:=format(mystr1,[myprovider,mydataprovider,myaccess]);
ADOConnection1.connected:=true;
ADOConnection1.GetTableNames(listbox1.Items);
end;
end;
procedure TForm1.ListBox1DblClick(Sender: TObject);
begin
ADOTable1.Close;
ADOTable1.TableName:=Listbox1.Items.Strings[listbox1.Itemindex];
ADOTable1.Open;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -