我用VB6连接SQL Server2005 ,总连不上,到底连接字该怎么写啊?
Dim cn   As New ADODB.Connection, rs     As New ADODB.Recordset
 Dim strSql As String
  
  strSql = "Provider=SQLNCLI;Server=127.0.0.1;Database=btdaj;Uid=test;Pwd=test;" 
  cn.Open strSql  
 ' 用户 'test' 登录失败。   数据库中已建test用户,并且能用test登录SQL2005  strSql = "provider=SQLOLEDB;Data Source=127.0.0.1;Database=btdaj;UID=sa;PWD=sapwd;"  
  cn.Open strSql
' 无法打开登录 'btdaj' 中请求的数据库。登录失败。   sa是能登录到sql2005中的以上两种写法都是从网上搜索到的,却不行,我不知是连接字错误,还是SQL2005中需有什么特殊设置?
我急需用,请大家帮忙!  多谢!        

解决方案 »

  1.   

    Provider=SQLOLEDB.1;Password=pass;Persist Security Info=True;User ID=user;Initial Catalog=db;Data Source=server
      
    *****************************************************************************
    欢迎使用CSDN论坛专用阅读器 : CSDN Reader(附全部源代码) 
    http://feiyun0112.cnblogs.com/
      

  2.   

    连接2005的实例:
    http://www.connectionstrings.com/?carrier=sqlserver2005
      

  3.   

    http://www.cnblogs.com/tongnaifu/archive/2008/10/21/1316141.html
      

  4.   

    我用上面的语句试了,仍提示用户test登录失败
       
     On Error GoTo Error
        Dim strSql As String
        Dim Cnn As adodb.Connection
        strSql = "Provider=SQLOLEDB.1;Password=test;Persist Security Info=True;User ID=test;Initial Catalog=test;Data Source=127.0.0.1 "
        Set Cnn = New adodb.Connection
         Cnn.Open strSql
         msgbox "ok"
         Exit Sub
    Error:
               MsgBox Err.Description
      

  5.   

    我的qq 号  391404966,哪位能通过QQ远程帮我看一下吗?