问一个关于动态创建ODBC数据源的问题(100分)

  • 主题发起人 主题发起人 linyuansheng888
  • 开始时间 开始时间
L

linyuansheng888

Unregistered / Unconfirmed
GUEST, unregistred user!
我的程序如下,但是我想修改几行程序,<br>让SQL SERVER应该如何验证登录ID的真伪?<br>这一项选择第二项使用用户输入登录ID和密码的SQL SERVER验证。<br>请问应该怎么修改?请高人不吝赐教<br>————————————————————————————————————————<br>unit showfrm;<br><br>interface<br><br>uses<br>&nbsp; Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,<br>&nbsp; Dialogs, jpeg, ExtCtrls, StdCtrls,Registry;<br><br>type<br>&nbsp; Tshowfrom = class(TForm)<br>&nbsp; &nbsp; Image1: TImage;<br>&nbsp; &nbsp; Label1: TLabel;<br>&nbsp; &nbsp; Date_lb: TLabel;<br>&nbsp; &nbsp; Label2: TLabel;<br>&nbsp; &nbsp; procedure FormCreate(Sender: TObject);<br><br>&nbsp; private<br>&nbsp; &nbsp; { Private declarations }<br>&nbsp; public<br>&nbsp; &nbsp; { Public declarations }<br>&nbsp; end;<br><br>var<br>&nbsp; showfrom: Tshowfrom;<br><br>implementation<br>const &nbsp;databaseName='SaleSystem';<br>const &nbsp;ODBCName='lin0932';<br>const &nbsp;Aboutname='Client';<br><br><br>{$R *.dfm}<br><br>procedure Tshowfrom.FormCreate(Sender: TObject);<br>var registerTemp : TRegistry;<br>begin<br>&nbsp; &nbsp;Date_lb.Caption:='今天是'+datetostr(now)+' &nbsp; &nbsp;';<br><br>&nbsp; &nbsp;begin<br>&nbsp; &nbsp; registerTemp := TRegistry.Create;<br>&nbsp; &nbsp;with registerTemp do<br>&nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; &nbsp;RootKey:=HKEY_LOCAL_MACHINE;<br><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if OpenKey('Software/ODBC/ODBC.INI/ODBC Data Sources',True) <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;WriteString( ODBCName,'SQL Server');<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;else<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Application.MessageBox('连接ODBC数据源失败.','提示',64);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; exit;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; &nbsp; &nbsp; CloseKey; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br><br>&nbsp; &nbsp; &nbsp; &nbsp;if OpenKey('Software/ODBC/ODBC.INI/'+ODBCName,True)<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; WriteString( 'Database', databaseName);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; WriteString( 'Description', Aboutname);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; WriteString('Driver','c:/WINDOWS/system32/sqlsrv32.dll' );<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Writestring('lastuser','sa');<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Writestring( 'Server', '210.34.145.254');<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Writestring( 'Pwd', '');<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Writestring( 'Trusted_Connection', 'Yes' );<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; writestring('Exclusive','No');<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; writestring('Null','Yes');<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; writestring('SetNoCountOn','No');<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;writestring('ImplicitCommitSync','');<br><br><br><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end<br>&nbsp; &nbsp; &nbsp; &nbsp; else<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Application.MessageBox('连接ODBC数据源失败.','提示',64);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;exit;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end;<br>&nbsp; &nbsp; CloseKey;<br>&nbsp; &nbsp; Free;<br>&nbsp; &nbsp;end;<br>&nbsp; end;<br>end;<br><br><br><br>end.
 
后退
顶部