我无法连接到Sql Server 2008和Visual Studio [英] I am unable to connect to Sql server 2008 and visual studio

查看:242
本文介绍了我无法连接到Sql Server 2008和Visual Studio的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hello
I installed SQL Server 2008 R2 and Visual Studio 2010 in my win7 32 bit. They were installed correctly. And each works well alone. But when I want to connect to SQL Server Management Studio from visual Studio I get this error:

SQLException was unhandled 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:Named Pipes Provider,error:40-could not open a connection to SQL Server)



这是我的连接代码:



This is my code for connection:

cn = new SqlConnection();
cn.ConnectionString = "Data Source=(local); Initial Catalog=XXX_amlak; User ID=sa; password=XXX";
cn.Open();

推荐答案

如果查看SQL Server配置管理器,您只会看到SQLEXPRESS实例名称,那么安装"的标准版会显示没有正确安装或根本没有安装.如果在Standard Edition的安装中,您只是单击了向导,则它可能已安装为默认实例.在这种情况下,您应该在配置管理器中看到一个MSSQLSERVER实例名称,或者您可以签入Window Services小程序(@运行提示符> services.msc).
If viewing SQL Server Configuration Manager you only see the SQLEXPRESS instance name, then the Standard edition you "installed" did not get installed properly or at all. If in the install of the Standard Edition you just clicked through the wizard it probably installed as the default instance. In this case you should see a MSSQLSERVER instance name in Configuration Manager, or you can check in the Window Services applet (@ Run prompt > services.msc).


尝试建立连接使用服务器资源管理器"并检查是否可以连接.如果可以的话,只需从那里复制连接字符串
try to have a connection using "Server Explorer" and check if able to connect. If fine just copy the connection string from there


这篇关于我无法连接到Sql Server 2008和Visual Studio的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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