关于在visual studio 2010中连接到sql server [英] regarding connecting to sql server in visual studio 2010

查看:206
本文介绍了关于在visual studio 2010中连接到sql server的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下午好,



i我正在尝试连接到visual studio 2010中的sql server。



我给连接字符串



SqlConnection con = new SqlConnection(Data Source =''RajasekharServer''; Initial Catalog = RajasekharDatabase; User Id = scott;密码= tiger;);



显示错误信息



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





它没有连接到SQL视觉工作室中的服务器。



请帮助我。

good afternoon,

i am trying to connecting to sql server which is present in visual studio 2010.

I am giving the connection string as

SqlConnection con = new SqlConnection("Data Source=''RajasekharServer'';Initial Catalog=RajasekharDatabase;User Id=scott;Password=tiger;");

it is showing the error message as

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)


it is not connecting to sql server which is present in visual studio.

please help me.

推荐答案

检查你的连接字符串将一些问题并将连接字符串放在Web中.Config



< connectionstrings>

< add name =DatabaseLogconnectionString = Data Source = DataSource; Initial Catalog = XYZ; Persist Security Info = True; User ID = ABC; Password = ABC/> < connectionstrings>
Check your connection string there will some issue and put connection string in Web.Config

<connectionstrings>
<add name="DatabaseLog" connectionString="Data Source=DataSource;Initial Catalog=XYZ;Persist Security Info=True;User ID=ABC;Password=ABC" /> <connectionstrings>


尝试使用visual studio 2010数据库连接向导获取适当的连接。



在菜单中,转到工具

- >连接数据库

- >弹出窗口将出现

- >输入服务器名称

- >如果配置,则使用sql authenticnticaltion模式

- >将出现一个数据库列表,选择您想要的数据库。



现在,转到Server Explorer,您的数据库将出现在列表中,右键单击它,属性窗口将出现在你可以看到连接字符串



只需复制该字符串并粘贴到web.config文件中



希望这会有所帮助
Try to get the appropriate connection using visual studio 2010 database connection wizard.

In the menu, go to Tools
-> Connect to database
-> A popup will appear
--> type the server name
--> use sql authenticaltion mode if configured
--> a list of database will appear, select your desired database.

Now, go to Server Explorer, your database will appear in the list, right click on it, a property window will appear under that you can see connection string

Just copy that string and paste in web.config file

Hope this will help


这篇关于关于在visual studio 2010中连接到sql server的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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