我现在做一个程序:由用户自行选择运行中间层程序的服务器。
如:现有一程序 A.exe 此程序是用于连接数据库 master 的,用户可以把此A.exe文件复制到 N01、N02、N03电脑中。当用户运行客户端时,选择中间服务器的名称是 N01或 N02 或N03。
注: 所有电脑中数据库表结构都是一样的,只是里边的数据内容不一样。如下表:
            N01                  N02              N03
-------------------------------------------------------------
  Table1   C001                  P001            N001  
           C002                  P002            N002
           C003                  P003            N003
现在的问题是:如果用户选择的N01电脑中的数据,得到的结果是:C001、C002、C003。如果用户退出所有程序,选择 N02电脑时,数据得到正确的 P001、P002、P003。
但如果用户选择了 N01电脑,返回C001、C002、C003数据,再去连接N02电脑时,正确的结果应该是:P001、P002、P003,但是数据并没有被刷新,还是返回C001、C002、C003,请问是什么原因?
**************************************************************
我用的是 Socker连接方式。
部份源码如下:
{********************************************************************************
  Name : connectiontoserver
  Desc : 连接服务器
  Path :
  Resu :
  Author : Hugo.CHEN 04-04-06 20:14
*********************************************************************************}
procedure TLoginform.Connectiontoserver;
begin
  if Trim(Edit3.Text)='' then
  begin
    MessageDlg('请输入需要连接的服务器名称!!', mtInformation, [mbOK], 0);
    Exit ;
  end ;//if Trim(Edit3.Text)='' then
  try
//Edit3.text 是用户选择运行中间程序的了服务器名称,中间程序已在相应的服务务器中运行注册过。
    mainform.SC_main.Connected := False ;
    mainform.SC_main.Host := Trim(Edit3.Text) ;
    mainform.SC_main.Connected := True ;
    combobox1.Items.Clear ;
    t_Accounts.Clear ;
    CDS_SERVER.Close ;
//取出数据表中的值并赋给TCombobox列表中。但是因为数据并没有刷新,
//如果连接同一个服务器,则数据正确,但是换另一个服务器后,数据并没有刷新
    CDS_Server.Active := False ;
    CDS_Server.CommandText := 'select * from NEXUS_ZT where ZT_STATE = 1 order by ZT_CODE' ;
    CDS_Server.Active := True ;
    if not CDS_Server.IsEmpty then
    begin
      CDS_Server.First ;
      while not CDS_Server.Eof do
      begin
        t_Accounts.Add(Trim(CDS_Server.fieldbyName('ZT_CODE').asstring)) ;
        combobox1.Items.Add(Trim(CDS_Server.fieldbyName('ZT_NAME').asstring)) ;
        CDS_Server.Next ;
      end ;//while not CDS_Server.Eof do
    end ;//if not CDS_Server.IsEmpty then
  except
    MessageDlg('连服服务器出错!', mtInformation, [mbOK], 0);
    Exit ;
  end ;//try
  combobox1.ItemIndex := 0 ;
end;