本工具可用于测试、生成Ado 数据库连接串!
下载
🔮 Ado Test
截图
代码
Unit1.pas
1unit Unit1;
2
3interface
4
5uses
6 Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
7 Dialogs, StdCtrls, DB, ADODB, ADOInt, ADOConst;
8
9type
10 TForm1 = class(TForm)
11 mmo1: TMemo;
12 btn1: TButton;
13 btn2: TButton;
14 con1: TADOConnection;
15 procedure btn1Click(Sender: TObject);
16 procedure btn2Click(Sender: TObject);
17 private
18 { Private declarations }
19 public
20 { Public declarations }
21 end;
22
23var
24 Form1: TForm1;
25
26implementation
27
28{$R *.dfm}
29
30procedure TForm1.btn1Click(Sender: TObject);
31begin
32 con1.Connected := false;
33 con1.ConnectionString := PromptDataSource(Handle, mmo1.Text);
34 mmo1.Text:=con1.ConnectionString
35end;
36
37procedure TForm1.btn2Click(Sender: TObject);
38begin
39 try
40 con1.Connected := false;
41 con1.ConnectionString := mmo1.Text;
42 con1.Connected := true;
43 ShowMessage('OK');
44 except
45 on E: Exception do
46 begin
47 ShowMessage(e.Message);
48 end;
49 end;
50end;
51
52end.
Unit1.dfm
1object Form1: TForm1
2 Left = 0
3 Top = 0
4 BorderStyle = bsDialog
5 Caption = 'ADO Test'
6 ClientHeight = 269
7 ClientWidth = 818
8 Color = clBtnFace
9 Font.Charset = DEFAULT_CHARSET
10 Font.Color = clWindowText
11 Font.Height = -11
12 Font.Name = 'Tahoma'
13 Font.Style = []
14 OldCreateOrder = False
15 Position = poDesktopCenter
16 PixelsPerInch = 96
17 TextHeight = 13
18 object mmo1: TMemo
19 Left = 8
20 Top = 8
21 Width = 802
22 Height = 193
23 ScrollBars = ssBoth
24 TabOrder = 0
25 end
26 object btn1: TButton
27 Left = 624
28 Top = 224
29 Width = 75
30 Height = 25
31 Caption = #26032#24314#36830#25509#20018
32 TabOrder = 1
33 OnClick = btn1Click
34 end
35 object btn2: TButton
36 Left = 720
37 Top = 224
38 Width = 75
39 Height = 25
40 Caption = #27979#35797
41 TabOrder = 2
42 OnClick = btn2Click
43 end
44 object con1: TADOConnection
45 LoginPrompt = False
46 Left = 264
47 Top = 152
48 end
49end