sql2000+三层+server端怎样动态连接SQL2000?(50分)

  • 主题发起人 主题发起人 bobo158
  • 开始时间 开始时间
B

bobo158

Unregistered / Unconfirmed
GUEST, unregistred user!
SERVER端怎样连接SQL2000? 要求动态配制连接信息:
在server端的RDM定义如下:
Ttest = class(TRemoteDataModule, Itest)
s_ADOQuery: TADOQuery;
s_adoconn: TADOConnection;
s_DataSetProvider: TDataSetProvider;
===================================
s_adoconn用于连接SQL2000,连接配置文件在PZ.INI中,如下:
===================
;服务器信息
[server]
target_sqlname=10.29.0.117
target_user=sa
target_pwd=035298ab
===============
我知道,在s_adoconn.connectstring,调出属性编辑器,
一步一步来,把user和password正确填写,最后
test connection,ok,可以连接SQL2000,但怎样动态指定s_adoconn的连接属性(IP,USER,PWD)呢? 以下方法不行:请高手指教.
============
server=record
name:string;
user:string;
pwd:string;
end;
s_server:server;
FExePath:STRING;
FiniFile:tinifile;

........
procedure TForm1.Button1Click(Sender: TObject);
begin
FExePath:=ExtractFilePath(Application.ExeName);
FiniFile:=TiniFile.Create(FExePath+'pz.ini');
s_server.name := finifile.ReadString('server','target_sqlname','') ;
s_server.user := finifile.ReadString('server','target_user','') ;
s_server.pwd := finifile.ReadString('server','target_pwd','') ;
freeandnil(finifile);
if not s_adoconn.Connected then
with test.s_adoconndo
begin
ConnectionString:='Provider=SQLOLEDB.1;Persist Security Info=False;User ID='+s_server.user +';Data Source='+s_server.name +';Password='+s_server.pwd +';';
Mode:=cmreadwrite ;
LoginPrompt:=false;
CursorLocation:=cluseclient;
//cluseclient;
clUseserver;
ConnectionTimeout:=1000;
Connected:=true;
//抱错
end;
end;
 
高手都哪里去了? 这个问题应该不难吧.
 
不錯可以看看。。。。
 
高手都哪里去了? 悲哉,高手之不存,论坛沦落至此,无语...
 
后退
顶部