8
8341
Unregistered / Unconfirmed
GUEST, unregistred user!
unit odbc;<br>interface<br>uses<br> Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,<br> Dialogs, StdCtrls;<br> const<br> c = 'DSN=MYSQL'#0+<br> 'DESCRIPTION=SQLConfigDSN Sample'#0 +<br> 'SERVER=(local)'#0 +<br> 'ADDRESS='#0 +<br> 'NETWORK='#0 +<br> 'DATABASE=pubs'#0#0;<br> const<br> ODBCCP32 = 'ODBCCP32.dll';<br>type<br> TForm1 = class(TForm)<br> Button1: TButton;<br> procedure Button1Click(Sender: TObject);<br> private<br> { Private declarations }<br> public<br> { Public declarations }<br> end;<br><br>function SQLConfigDataSource(hWnd: HWND; Request: LongInt; DriverType: PChar;<br> Attributes: PChar): BOOL; stdcall;<br><br>var<br> Form1: TForm1;<br>implementation<br><br>{$R *.dfm}<br><br>procedure TForm1.Button1Click(Sender: TObject);<br>begin<br> try<br> SQLConfigDataSource(0, 4, 'SQL Server', c);<br> except<br> showmessage('创建错误!');<br> end;<br>end;<br><br>function SQLConfigDataSource; external ODBCCP32 name 'SQLConfigDataSource';<br><br>end.<br><br>运行后,也没有报错,但是在ODBC数据原中却没有任何新的项目出现,注册表也没有变化,怎么回事?