解决方案 »

  1.   

    不通过BDE,ODBC
      不知道类似这样写能不能实现 :
      adoconnection.connectstring:='provider=XXXX;remote server=192.168.1.1;'
      

  2.   

    function TdmDataBase.gfConnectData(AAdoCon:TAdoConnection;AServerName,ADBName,AUserID,APassWord:String;AConType:TConnectionType):Boolean;
    var sConnect:String;
    begin
      if AAdoCon.Connected then AAdoCon.Connected:=False;
      Case AConType of
        ctSqlServer:
          begin
            sConnect:='Provider=SQLOLEDB.1;Password='+APassword
                      +';Persist Security Info=True;User ID='+AUserID
                      +';Initial Catalog=master;Data Source='
                      +AServerName+';Use Procedure for Prepare=1;Auto Translate=True;Packet Size=8192;Workstation ID='+AServerName;
            AAdoCon.DefaultDatabase:=ADBName;
          end;
        ctOracle:
          sConnect:='Provider=MSDAORA.1;User ID='+AUserID
                    +';Password='+APassword
                    +';Data Source='+AServerName
                    +';Persist Security Info=False';
      end; //end of Case
      AAdoCon.ConnectionString:=sConnect;
      try
        AAdoCon.Connected:=true;
      except
        Exit;
      end;
      Result:=True;
    end;//其中为枚举类型,表示数据连接类型 TConnectionType  = (ctOracle, ctSqlServer);