如何在ASP.NET中的web.config中定义外部数据库的连接字符串 [英] How to define connection string of external database in web.config in ASP.NET
本文介绍了如何在ASP.NET中的web.config中定义外部数据库的连接字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在添加标签中定义属性,如键和名称
以及如何使用该属性连接外部数据库
How to define attribute in add tag like key and name
and how to use that attribute to connect external DB
推荐答案
web .config //像这样定义
web.config //define like this
<connectionstrings>
<add name="TestConnectionString" connectionstring="Data Source=.;Initial Catalog=Test;Integrated Security=True">
providerName="System.Data.SqlClient" />
</add></connectionstrings>
和.cs文件这样检索
and .cs files retrieve like this
string conn_string = ConfigurationManager.ConnectionStrings["TestConnectionString"].ConnectionString;
请尝试以下链接 -
在web.config中存储连接字符串 [ ^ ]
SQL Server ASP.NET Web应用程序的连接字符串 [ ^ ]
Try the following links -
Store connection string in web.config[^]
SQL Server Connection Strings for ASP.NET Web Applications[^]
<connectionstrings>
<add name="TestConnectionString" connectionstring="Data Source=192.168.1.2;Initial Catalog=Test;Integrated Security=True">
providerName="System.Data.SqlClient" />
</add></connectionstrings>
这里,192.168.1.2是IP地址数据库所在的其他系统......
Here, 192.168.1.2 is the IP address of the other system where your database is situated...
这篇关于如何在ASP.NET中的web.config中定义外部数据库的连接字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文