ASP.NET 链接数据库的两种配置
利用跨库搜索,如Ecosis链接不同数据库以获取完整文献 #生活技巧# #学习技巧# #学术论文检索技巧#
打开 Web.config
链接方法①(推荐)
<connectionStrings>
<add name="DefaultConnection" providerName="System.Data.SqlClient" connectionString="Data Source=127.0.0.1;Initial Catalog=pagerTest;User ID=sa;Password=123"/>
</connectionStrings>
链接方法②
<appSettings>
<add key="connStr" value="server=127.0.0.;uid=sa;pwd=123;database=pagerTest" />
</appSettings>
方法①在CS中的使用:
string str=System.Configuration.ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString;
SqlConnection sqlstr = new SqlConnection(str);
或者
string str=System.Configuration.ConfigurationManager.ConnectionStrings["DefaultConnection"].ToString();
SqlConnection sqlstr = new SqlConnection(str);
方法②在CS中的使用:
string str=System.Configuration.ConfigurationManager.appSettings["connStr"].ToString();
SqlConnection sqlstr = new SqlConnection(str);
网址:ASP.NET 链接数据库的两种配置 https://www.yuejiaxmz.com/news/view/888069
相关内容
数据库链接错误 : No such file or directoryasp.net WEBSocket简单例子 推送数据
ORCL 数据库的安装配置
打造高效便捷的在线购物平台:ASP.NET网上购物系统源代码推荐
创建简单的数据驱动 CRUD 微服务
sparkSQL 连接读取Oracle数据库
数据库和生活有什么连接
ASP.NET从入门到精通(第2版)【全本
判断数据库连接状态
数据库连接对象Connection对象的获取及相关知识总结