c/s结构系统,数据库服务器的ip(固定ip)为:***.***.***.***
怎么编写客户端连接对象?

解决方案 »

  1.   

    写一个配置文件,写在登陆里面就可以了
    procedure Tlogin.formcreate(sender:tobject);
    var
      ini:tinifile;
      ip:string;
    begin
      if not fileexists('.\config.ini') then
      begin
        messagedlg('配置文件不存在',mtinformation,[mbOK],0);
        application.terminate;
        exit;
      end;
      ini:= tinifile.create('.\config.ini');
      ip:= ini readstring('databaseip:','ip','127.0.0.1');
      adoquery.connectionstring:= 'provider=sqloledb.1;password=123;persist security info=true; user id=abc;initial catalog=asd;data source='+ip;
      ini.free;
    end;
    就这样了,然后在生成的配置文件里面指定数据库所在服务器的ip 或者数据库的名字就ok了