在 VS2012 中无法连接到 localDB –“与 SQL Server 建立连接时发生与网络相关或特定于实例的错误..."

编程入门 行业动态 更新时间:2024-10-26 02:27:25
本文介绍了在 VS2012 中无法连接到 localDB –“与 SQL Server 建立连接时发生与网络相关或特定于实例的错误..."的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

这很奇怪,因为我能够通过 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=&lt;databasename&gt; 其中 <databasename>是我通过 ssms 在 localdb 上创建的.

I have also tried specifying the database Initial Catalog=&lt;databasename&gt; 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 建立连接时发生与网络相关或特定于实例的错误..."

本文发布于:2023-11-02 13:43:52,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1552551.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:连接到   实例   生与   错误   网络

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!