Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- unit Unit1;
- interface
- uses
- Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
- Dialogs, DB, ADODB, StdCtrls, Grids, DBGrids, AdoConEd, XPMan;
- type
- TForm1 = class(TForm)
- AC: TADOConnection;
- EP: TEdit;
- AT: TADOTable;
- ET: TEdit;
- DS: TDataSource;
- DBGrid1: TDBGrid;
- Button1: TButton;
- procedure Button1Click(Sender: TObject);
- procedure FormActivate(Sender: TObject);
- private
- { Private declarations }
- public
- { Public declarations }
- end;
- var
- Form1: TForm1;
- implementation
- {$R *.dfm}
- procedure TForm1.Button1Click(Sender: TObject);
- begin
- AC.Close;
- AC.ConnectionString := EP.Text;
- if EditConnectionString(AC) then
- begin
- EP.Text := AC.ConnectionString;
- AT.ConnectionString := EP.Text;
- AT.TableName := ET.Text;
- AC.Connected := true;
- AT.Active := true;
- Caption := AC.DefaultDatabase;
- end;
- end;
- procedure TForm1.FormActivate(Sender: TObject);
- var
- Path : String;
- begin
- Path := ExtractFilePath(Application.ExeName)+'ZS.mdb';
- if not FileExists(Path) then
- exit
- else
- AC.Close;
- AC.LoginPrompt := false;
- EP.Text := 'Provider=Microsoft.Jet.OLEDB.4.0;Data Source='+Path+';Persist Security Info=False';
- AC.ConnectionString := EP.Text;
- AT.ConnectionString := EP.Text;
- AT.TableName := ET.Text;
- AC.Connected := true;
- AT.Active := true;
- end;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement