找不到指定的SQl Server Vb前台,msSql後台.程序運行時出現如下錯誤提示:<<<執行階段錯誤'-2147467259(80004005):[DBNMPNTGW]找不到指定的SQl Server.>>>調試時,出錯代碼為登錄數據庫時的code.求解法。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 回復:登錄數據庫的信息寫在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=" + HostNameEnd Sub'///////////////////////////////////////// pubSQLcnn.ConnectionString = pubCnnString pubSQLcnn.Open , pubLogin, pubPassWord 应该是网络库协议设置不准确,治标方法可以在odbc中将命名管道改为tcp/ip,治本方法是安装mdac_typ.exe,vb6安装盘里面有! 从代码来看看不出有错误。同意楼上的将缺省连接由命名管道改为TCP/IP模式。 先用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下载运行 1,安装最新的mdac_typ.exe2,在控制面板中手工配制ODBC到SQL 謝謝大家的關注,下載安裝MDAC_typ.exe後,問題得到解決。謝謝各位的指導! vb6.0 控件加载utf-8格式的文件出现乱码 我在表中查询一条记录,怎样才能知道,这条记录在表中的第几行呢?? 龙卷风缩略图水印组件1.0版发布了 一个关于加密ACCESS连接ADO控件的问题! 数据库连接的问题,大家帮忙看看.急须帮忙 VB6 adodc 导出excel的问题(可否指定字段导出) 大家说说看!! 请教,有个VB编程问题(求助) ADO数据连接的问题 用API将文件读入内存ReadFile紧急求救 哪里可以找到关于opengl编程的资料?要中文版的。 哈哈,痛苦啊~啥时候又挨多穿了第三件三角裤哦~
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
安装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
下载运行
2,在控制面板中手工配制ODBC到SQL
謝謝各位的指導!