使用WebConfig进行连接 [英] Connection using WebConfig
本文介绍了使用WebConfig进行连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
朋友,
解决方案
在web.config中,如何添加连接字符串条目:
<connectionstrings><br /> <add><br /> name="LocalSqlServer" <br /> connectionString="Data Source=amit\sqlexpress;Initial <br /> Catalog=MyDatabase;User ID=userName;Password=password"<br /> providerName="System.Data.SqlClient"<br /> /><br /> </add></connectionstrings>
然后在
.cs页U可以使用
获得连接
SqlConnection con =新的SqlConnection(ConfigurationManager.ConnectionStrings ["LocalSqlServer"].ConnectionString);
检查一下
http://www.aspdotnet-suresh.com/2011/11/write-connection-strings-in-webconfig.html [ ^ ]
您可以按照以下简单步骤从Visual Studio本身获取连接字符串
^ ]
并复制连接字符串并将其放在web.config中.
设置连接字符串的一些方法,您可以从
找到 http://www.connectionstrings.com/Articles/Show/store-connection-string-in-web-config [ ^ ]
Hi Friends,
How to connect sqlServer in asp.net through webconfig?
解决方案
In your web.config, add a connection string entry:
<connectionstrings><br /> <add><br /> name="LocalSqlServer" <br /> connectionString="Data Source=amit\sqlexpress;Initial <br /> Catalog=MyDatabase;User ID=userName;Password=password"<br /> providerName="System.Data.SqlClient"<br /> /><br /> </add></connectionstrings>
and then on
.cs Page U can get connection by Using
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["LocalSqlServer"].ConnectionString);
Check this out
http://www.aspdotnet-suresh.com/2011/11/write-connection-strings-in-webconfig.html[^]
You can get Connection String from visual studio itself by following some simple steps
Get SQL Server Database Connection String Easily from Visual Studio[^]
and copy connection string and put it in web.config.
Some of ways to set connection string you find from
http://www.connectionstrings.com/Articles/Show/store-connection-string-in-web-config[^]
这篇关于使用WebConfig进行连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文