在form中放一个ADOCOnnection1,双击进入设置,选择第二项:use connection string .在"提供程序"中选择"Micosoft OLE DB Provider for SQL Server " 下一步在 选择或输入服务器名中我输入的是:127.0.0.1 ,选择"使用Windows NT 集成安全登入.然后在服务器上选择数据库.
为什么有时可以有时不可以?

解决方案 »

  1.   

    网络通不通啊
    用  ping  127.0.0.1 试试
      

  2.   

    最好不用nt集成登录, nt集成登录如果换机器运行的话,要求你局域网中有域服务器,
      

  3.   

    既然是127.0.0.1,还不如输入(local)
      

  4.   

    ********
    用Windows NT 集成安全登入.然后在服务器上选择数据库.
    为什么有时可以有时不可以?
    **********
    选指定用户名和密码
    用户名为SA 密码(我不知道)
      

  5.   

    procedure TDM1.SaveDBConn(var DBConn: TADOConnection);
    var
      ConnFile:TStringList;
      SConn:wideString;
    begin
               ConnFile:=TStringList.Create;
                with DBConn do
                begin
                    SConn:='Provider='+ Provider+';';
                    SConn:=SConn+'Data Source='+Properties['Data Source'].Value+';';
                    SConn:=SConn+'User ID=' +Properties['User ID'].Value +';';
                    SConn:=SConn+'Password='+Properties['Password'].Value+';';                if  (pos('SQLOLEDB',Provider)>0) then
                    begin
                    if  Properties['Persist Security Info'].Value=true then
                       SConn:=SConn+'Persist Security Info=True;'
                    else
                      SConn:=SConn+'Persist Security Info=false;';
                    
                       SConn:=SConn+'Initial Catalog='+Properties['Initial Catalog'].Value +';';
                    end;
               end;
               ConnFile.Text:=SConn;
               ConnFile.Savetofile(ExtractFilePath(Application.ExeName)+'JGDSystem\ConnIni.dat');
               ConnFile.Free;
    end;
      

  6.   

    ip地址它不认得,好像使用的NETBIOS名字