无法连接到的LocalDB在VS2012 - "同时建立到SQL Server ...&QUOT连接时出现与网络相关的或特定于实例的错误; [英] Unable to connect to localDB in VS2012 – "A network-related or instance-specific error occurred while establishing a connection to SQL Server..."

查看:278
本文介绍了无法连接到的LocalDB在VS2012 - "同时建立到SQL Server ...&QUOT连接时出现与网络相关的或特定于实例的错误;的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是奇怪,因为我可以通过SSMS 2008 R2使用相同的连接字符串连接到的LocalDB(数据源=(的LocalDB)\ 11.0;集成安全性=真

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# code是无法接通,我试图增加登录时间连接超时= 60 但没有运气。

Only C# code is unable to connect, I have tried increasing login time with Connect Timeout=60 but no luck.

我也试图指定数据库初始目录=安培;其中,数据库名称和放大器; GT; ,其中的<数据库名称>是一个我已通过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)\\ 11.0;集成安全性=真正的

甚至更好,你可以只使用了 @ 标记,以禁用字符转义为整个连接字符串:

Or even better, you could just use the @ mark to disable character escaping for the entire connection string:

@数据源=(的LocalDB)\ 11.0;集成安全性=真正的

这篇关于无法连接到的LocalDB在VS2012 - &QUOT;同时建立到SQL Server ...&QUOT连接时出现与网络相关的或特定于实例的错误;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆