使用 SQLConnection 和 ConnectionString 以编程方式解决 VistaDB 连接问题

发布于 2024-07-07 04:08:31 字数 642 浏览 6 评论 0 原文

我在使用 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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

淑女气质 2024-07-14 04:08:31

您不能将 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文