Vb前台,msSql後台.程序運行時出現如下錯誤提示:
<<<執行階段錯誤'-2147467259(80004005):[DBNMPNTGW]找不到指定的SQl Server.>>>
調試時,出錯代碼為登錄數據庫時的code.
求解法。

解决方案 »

  1.   

    回復:登錄數據庫的信息寫在INI文件中。部分簡體可以用,部分繁體可以用。
    Public Sub ReadINI()
        Dim ret As Long
        Dim buff As String
        Dim HostName As String
        Dim DbName As String
        
    '    '
        buff = String(256, 32)
        ret = GetPrivateProfileString("Depot", "HostName", "HostName", buff, 255, CurDir + "\client.ini")
        HostName = Trim(buff)
        HostName = Left(HostName, Len(HostName) - 1)‘取得服務器 IP
        '
        buff = String(256, 32)
        ret = GetPrivateProfileString("Depot", "DbName", "DbName", buff, 256, CurDir + "\client.ini")
        DbName = Trim(buff)
        DbName = Left(DbName, Len(DbName) - 1)'取得數據庫名
        '
        buff = String(256, 32)
        ret = GetPrivateProfileString("Depot", "Login", "Login", buff, 256, CurDir + "\client.ini")
         pubLogin = Trim(buff)
         pubLogin = Left(pubLogin, Len(pubLogin) - 1)'取得用戶名
        '
        buff = String(256, 32)
        ret = GetPrivateProfileString("Depot", "PassWord", "PassWord", buff, 256, CurDir + "\client.ini")
        pubPassWord = Trim(buff)
        pubPassWord = Left(pubPassWord, Len(pubPassWord) - 1)'取得密碼
    '
       pubCnnString = "Provider=SQLOLEDB.1;Persist Security Info=False;Initial Catalog=" + DbName + ";Data Source=" + HostName
    End Sub
    '/////////////////////////////////////////
     pubSQLcnn.ConnectionString = pubCnnString
       pubSQLcnn.Open , pubLogin, pubPassWord
      

  2.   

    应该是网络库协议设置不准确,治标方法可以在odbc中将命名管道改为tcp/ip,治本方法是安装mdac_typ.exe,vb6安装盘里面有!
      

  3.   

    从代码来看看不出有错误。同意楼上的将缺省连接由命名管道改为TCP/IP模式。
      

  4.   

    先用odbc连接试试然后
    安装mdac2.6驱动
    http://download.microsoft.com/download/dasdk/Install/2.60.6526.3/WIN98Me/EN-US/MDAC_TYP.EXEMicrosoft MDAC2.8支持程序
    http://www.cclis.com/download.asphttp://www.12300.net/book/mdac_typ2.7.exe
    下载运行
      

  5.   

    1,安装最新的mdac_typ.exe
    2,在控制面板中手工配制ODBC到SQL
      

  6.   

    謝謝大家的關注,下載安裝MDAC_typ.exe後,問題得到解決。
    謝謝各位的指導!