我在使用 web.config 文件中的连接字符串连接到 VistaDB 时遇到错误。
在我指定 ProviderName 后,使用 SQLDataSource 可以正常工作。 在另一页上,我仅在代码中进行连接,
这是连接字符串的代码:
Public Function CreateConnection() As SqlConnection
_connectionString = ConfigurationManager.ConnectionStrings("ConnectionString").ToString()
返回新的 SqlConnection(_connectionString)
结束函数
这是错误:
与网络相关或特定于实例的
建立时发生错误
连接到 SQL Server。 服务器
未找到或无法访问。
验证实例名称是否为
正确并且 SQL Server 是
配置为允许远程
连接。 (提供商:SQL 网络
接口,错误:26 - 错误定位
指定服务器/实例)
如何解决此错误?
I'm getting an error connecting to a VistaDB using a connection string in the web.config file.
It works fine using a SQLDataSource AFTER I specified the ProviderName. On another page I'm only connecting in code and
Here is the code for the connection string:
Public Function CreateConnection() As SqlConnection
_connectionString = ConfigurationManager.ConnectionStrings("ConnectionString").ToString()
Return New SqlConnection(_connectionString)
End Function
Here is the error:
A network-related or instance-specific
error occurred while establishing a
connection to SQL Server. The server
was not found or was not accessible.
Verify that the instance name is
correct and that SQL Server is
configured to allow remote
connections. (provider: SQL Network
Interfaces, error: 26 - Error Locating
Server/Instance Specified)
How can I resolve this error?
发布评论
评论(1)
您不能将 SqlConnection 与 VistaDB 连接字符串一起使用。 这是您从 SQL Server 收到的错误 - 它找不到该服务器。
请改用 VistaDBConnection。
You can't use a SqlConnection with a VistaDB connection string. That is the error you are getting from SQL Server - it can't find that server.
Use a VistaDBConnection instead.