Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/visual-studio-2010/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql server 2008 r2 我无法从Visual Studio 2010连接到SQL Server 2008 R2_Sql Server 2008 R2_Visual Studio 2010 - Fatal编程技术网

Sql server 2008 r2 我无法从Visual Studio 2010连接到SQL Server 2008 R2

Sql server 2008 r2 我无法从Visual Studio 2010连接到SQL Server 2008 R2,sql-server-2008-r2,visual-studio-2010,Sql Server 2008 R2,Visual Studio 2010,我在Win7 32位上安装了SQL Server 2008 R2。它安装正确并生成了一个数据库。我打开了VisualStudio2010,并编写了一段连接到SQLServer的代码 cn = new SqlConnection(); cn.ConnectionString = "Data Source=(local); Initial Catalog=XXX_amlak; User ID=sa; password=XXX"; cn.Open(); 但我得到了这个错误 SQLException未

我在Win7 32位上安装了SQL Server 2008 R2。它安装正确并生成了一个数据库。我打开了VisualStudio2010,并编写了一段连接到SQLServer的代码

cn = new SqlConnection();
cn.ConnectionString = "Data Source=(local); Initial Catalog=XXX_amlak; User ID=sa; password=XXX";
cn.Open();
但我得到了这个错误

SQLException未处理
建立数据库时发生与网络相关或特定于实例的错误 连接到SQL Server。找不到服务器或无法访问服务器。 验证实例名称是否正确,以及SQL server是否配置为 允许远程连接。(提供程序:命名管道提供程序,错误:40无法打开。) 与SQL Server的连接)


Visual Studio已自动安装SQL Server Express。

我很困惑。。。您正在尝试连接到Sql Server 2008 R2实例,还是连接到Visual Studio安装的Sql Express实例?很可能您已经安装了Sql 2008R2 Express。您必须更改连接字符串,以便数据源=(local\SQLEXPRESS)我正在尝试连接到SQL Server 2008 R2。到SQL管理工作室。