Invalid Instance when using ADODB.Recordset

偶尔善良 提交于 2019-12-08 09:50:36

问题


I have migrated from one sever to another. I have restored my database and reset up my website. Since migrating however my website will not connect to the database I am getting the following error:

Microsoft OLE DB Provider for SQL Server error '80004005'

[DBNETLIB][ConnectionOpen (Invalid Instance()).]Invalid connection.

My connection string is in the form of

CON_STRING = "Provider=SQLOLEDB;Data Source=myserver;Initial Catalog=mydb;User Id=user;Password=password"

The error is being thrown on the second line of the code below

Set rsBCT = Server.CreateObject("ADODB.Recordset")
rsBCT.ActiveConnection = CON_STRING

Would there be anything settings wise on the server that would need changing for this work? How can I try and debug what is going wrong. All my other applications which use web.config files are connecting fine. What troubleshooting steps can I take?


回答1:


Use the instance name of the server in the connection string:

CON_STRING = "Provider=SQLOLEDB;Data Source=myServer\myInstance;Initial Catalog=mydb;User Id=user;Password=password"
----------------------------------------------------^^^^^^^^^^^



回答2:


You may try to connect SQL instance higher than your OLEDB client version.

Therefore you can try to change your provider to "SQLNCLI" (Native SQL Client)

CON_STRING = "Provider=SQLNCLI;Data Source=myServer;Initial Catalog=mydb;User Id=user;Password=password"


来源:https://stackoverflow.com/questions/4156301/invalid-instance-when-using-adodb-recordset

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!