How to change TmsConnection Server

Discussion of open issues, suggestions and bugs regarding SDAC (SQL Server Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
Posts: 2
Joined: Mon 02 Apr 2012 07:27

How to change TmsConnection Server

Post by tiger » Fri 06 Apr 2012 06:14

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.


Post by AndreyZ » Fri 06 Apr 2012 14:51


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.

Post Reply