如何用delphi连接远程数据库(sql server2000)最好是可以用ado(不知道是不是控件),其他方法也可以。
有两种情况:1、知道数据库所在服务器的IP地址,如何连接,是不是得有什么连接串??
           2、在程序安装的时候才可以知道服务器的IP地址,就是可以动态的连接数据库,这时候的连接串应该怎样写??
初学delphi请大家帮帮忙,说的时候能不能尽量说的详细一点,在这里先谢了!!!

解决方案 »

  1.   

    1 用socket 连接,三层吧
    2 socket.appress:=Ip
      

  2.   

    Provider=SQLOLEDB.1;Password=ncase;Persist Security Info=True;User ID=sa;Initial Catalog=fxncaseerp;Data Source=127.0.0.1
    把上面的PASSOWRD和FXNCASEERP和127.0。0.1改为你的就可以了
      

  3.   

    不是,应该就是两层吧!就是客户端与服务器的数据库连接吧!
    socket是什么?怎么用??能说的详细一点吗??
      

  4.   

    to ziqing(delphi转.net中) :
    是不是必须用adoconnection控件???是不是在程序运行的时候写“Provider=SQLOLEDB.1;Password=ncase;Persist Security Info=True;User ID=sa;Initial Catalog=fxncaseerp;Data Source=127.0.0.1”就与数据库连接上了呢?
      

  5.   

    要用到adoconnection,在程序运行是写‘Provider=SQLOLEDB.1;Password=ncase;Persist Security Info=True;User ID=sa;Initial Catalog=fxncaseerp;Data Source=127.0.0.1’
    当你想连接远程数据库时,只要将Data Source=远程主机的ip或主机名就行了
      

  6.   

    Provider=SQLOLEDB.1;Password=ncase;Persist Security Info=True;User ID=sa;Initial Catalog=fxncaseerp;Data Source=127.0.0.1
    把上面的PASSOWRD和FXNCASEERP和127.0。0.1改为你的就可以了
    也可以吧data source,用户名,密码这些值写在配置文件中,那样就比较容易修改了。
    但是不太安全
      

  7.   

    要用到adoconnection,在程序运行是写‘Provider=SQLOLEDB.1;Password=ncase;Persist Security Info=True;User ID=sa;Initial Catalog=fxncaseerp;Data Source=127.0.0.1’
    当你想连接远程数据库时,只要将Data Source=远程主机的ip或主机名就行了
      

  8.   

    可以在运行时写,也可以一开始就设定。
    一样,都没设置ADOConnection的ConnectionString属性。
    设计时点ADOConnection的ConnectionString进行相关属性。运行时可以通过从配置文件里(方便修改)读相关信息改ADOConnection的ConnectionString的属性值。
    例:
    Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=201Cash;Data Source=192.168.1.118
      

  9.   

    我找到这样一段代码:
    {连接SQL Server
    function Tdm.GetConnectionString: Boolean;
    var
      SYSINI: TINIFile;
      ServerName, UserName, Password, InitDB: string;
    begin
      Result := False;
      gDB.Connected := False;
      if gDB.Connected = False then begin
         try
           SYSINI := TIniFile.Create(ExtractFilePath(Application.ExeName) + IniFileName);
           ServerName := SYSINI.ReadString('Database', 'ServerName', '127.0.0.1');
           UserName := SYSINI.ReadString('Database', 'UserName', 'sa');
           InitDB := SYSINI.ReadString('Database', 'InitDB', 'DevData');
           Password := SYSINI.ReadString('Database', 'Password', '');
         finally
           SYSINI.Free;
         end;
      end;  try
        gDB.ConnectionString := 'Provider=SQLOLEDB;Password='
          + Password + ';Persist Security Info=True;User ID='
          + UserName + ';Initial Catalog=' + InitDB
          + ';Data Source=' + ServerName;
        gDB.Connected := True;
        Result := True;
      except
        Result := False;
      end;
    end;}INI文件:
    [Database]
    ServerName=127.0.0.1
    InitDB=DevData
    UserName=sa
    Password=
    关于ini文件具体应该怎么用呀?还请大家多帮忙!!!多谢!!!
      

  10.   

    为什么我把"connectstring"设为Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=201Cash;Data Source=192.168.0.10后还是连接不到数据库呢??
      

  11.   

    客户端还用装关于sql server的什么东东,或者文件什么的吗?为什么我总是连接不上数据库???能找到服务器,但是找不到库!!!
      

  12.   

    你在登录窗口上设置一个可以修改ip地址的地方.到时候根据用户输入的ip 来动态的生成连接字符串