📄 unit1.~pas
字号:
{本源码是自由程序,你可以把它用在任何地方,但不允许以任何形式把它单独用作商业用途。
本人是一个普通的打工仔,为了给朋友们献上更好的源码和控件,我需要你的支持,如果你认为本程序对你有帮助,希望你寄任意你愿意数额的RMB给我以资鼓励和支持,如果你认为不值,也希望你寄一张PostCard或者一封Email对我予以支持。
深圳市福田区联合广场41楼恒星威电子有限公司GPS部 艾真保 收
518026
mailto:Aizb@163.net
HomePage:
http://www.aidelphi.com}
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Grids, DBGrids, DB, ADODB;
type
TForm1 = class(TForm)
ADOQuery1: TADOQuery;
DataSource1: TDataSource;
Button1: TButton;
OpenDialog1: TOpenDialog;
ADOConnection1: TADOConnection;
ListBox1: TListBox;
Button2: TButton;
DBGrid1: TDBGrid;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
OpenDialog1.InitialDir:=ExtractFilePath(Application.ExeName);
if OpenDialog1.Execute then
begin
if FileExists(OpenDialog1.FileName) then
begin
ADOConnection1.Close;
ADOConnection1.LoginPrompt:=False;
ADOConnection1.ConnectionString:=
'Provider=MSDASQL.1;Persist Security Info=False;Extended Properti' +
'es="DSN=MS Access Database;DBQ='+OpenDialog1.FileName+';DefaultDir='+ExtractFilePath(OpenDialog1.FileName)+';DriverId=281;FIL=MS Access;MaxBufferSi' +
'ze=2048;PageTimeout=5;UID=admin;"';
ADOConnection1.GetTableNames(ListBox1.Items);
end;
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
if ListBox1.ItemIndex>=0 then
begin
DataSource1.DataSet:=ADOQuery1;
DBGrid1.DataSource:=DataSource1;
ADOQuery1.DisableControls;
try
ADOQuery1.Close;
ADOQuery1.Connection:=ADOConnection1;
ADOQuery1.SQL.Text:='Select * from '+ListBox1.Items[ListBox1.itemindex];
ADOQuery1.Open;
finally
ADOQuery1.EnableControls;
end;
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -