Page 1 of 1

How to change TmsConnection Server

Posted: Fri 06 Apr 2012 06:14
by tiger
I have 3 DataBase(name A , B ,C) in 2 Servers, When User Login successed, he selected any one DataBase, My Program code in datamodule on create Even. Follow...

//wkComSrvNo , wkComDbs is variable from .ini file

fbjdm.DataBase1.Connected := False;
fbjdm.DataBase2.Connected := False;


fbjdm.DataBase1.ConnectString := 'Provider=SQLOLEDB.1;User ID=erpuser;Password=xxxxxx;Data Source='+wkComSrvNo+';'+
'Initial Catalog='+wkComDbs+';Persist Security Info=True';


fbjdm.DataBase2.ConnectString := 'Provider=SQLOLEDB.1;User ID=erpuser;Password=xxxx;Data Source='+wkComSrvNo+';'+
'Initial Catalog=bjpub;Persist Security Info=True';
fbjdm.DataBase1.Connected := True;
fbjdm.DataBase2.Connected := True;
//---------------------------------------------------
when program run in main form some question happen
msuqery.connection values can't change user selected Server and DataBase. The Msquery.Connection still old value .

I saw ChangeNotification already, but I can't understood.
Please tell me detail or others method.

Posted: Fri 06 Apr 2012 14:51
by AndreyZ
Hello,

I cannot reproduce the problem. When you set the TMSConnection.ConnectString property, the TMSConnection.Server property is set to the value of the "Data Source" option of the connection string. If TMSQuery.Connection.Server has the old value after setting the ConnectString property, most likely, it means that it is connected to another connection.