Unable to connect to localDB in VS2012 – quot;A network-related or instance-specific error occurred while establishing a connection to SQL Server...quot;(在 VS2012 中无法连接到 localDB –“与 SQL Server 建立连接时发生与网络相关或特定于实例的错误...) - IT屋-程序员软件开发技术分享
问题描述
这很奇怪,因为我能够通过 SSMS 2008R2 使用相同的连接字符串 ("Data Source=(LocalDB)v11.0;Integrated Security=true
") 连接到 localDB
This is strange as I'm able to connect to localDB through SSMS 2008R2 with the same connection string ("Data Source=(LocalDB)v11.0;Integrated Security=true
")
只有 C#
代码无法连接,我尝试使用 Connect Timeout=60
增加登录时间,但没有成功.
Only C#
code is unable to connect, I have tried increasing login time with Connect Timeout=60
but no luck.
我还尝试指定数据库 Initial Catalog=<databasename>
其中 <databasename>是我通过 ssms 在 localdb 上创建的.
I have also tried specifying the database Initial Catalog=<databasename>
where the <databasename> is the one I have created on localdb via ssms.
关于为什么不连接的任何指针?
Any pointers as to why is this not connecting?
推荐答案
有没有可能是因为你忘记了双转义反斜杠?你试过这个吗:
Any chance it is because you forgot to double-escape the backslash? Did you try this:
"数据源=(LocalDB)\v11.0;Integrated Security=true"
或者更好的是,您可以只使用 @
标记来禁用整个连接字符串的字符转义:
Or even better, you could just use the @
mark to disable character escaping for the entire connection string:
@"Data Source=(LocalDB)v11.0;Integrated Security=true"
这篇关于在 VS2012 中无法连接到 localDB –“与 SQL Server 建立连接时发生与网络相关或特定于实例的错误..."的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在 VS2012 中无法连接到 localDB –“与 SQL Server 建立连接时发生与网络相关或特定于实例的错误..."


基础教程推荐
- 是否可以在 asp classic 和 asp.net 之间共享会话状态 2022-01-01
- 首先创建代码,多对多,关联表中的附加字段 2022-01-01
- 经典 Asp 中的 ResolveUrl/Url.Content 等效项 2022-01-01
- JSON.NET 中基于属性的类型解析 2022-01-01
- 将事件 TextChanged 分配给表单中的所有文本框 2022-01-01
- 错误“此流不支持搜索操作"在 C# 中 2022-01-01
- 全局 ASAX - 获取服务器名称 2022-01-01
- 从 VS 2017 .NET Core 项目的发布目录中排除文件 2022-01-01
- 在 VS2010 中的 Post Build 事件中将 bin 文件复制到物 2022-01-01
- 如何动态获取文本框中datagridview列的总和 2022-01-01