读取区块连接字符串设置值
2007-08-20 22:12
260 查看
读取<connectionStrings>区块连接字符串设置值
string conn1 = ConfigurationManager.ConnectionStrings["LocalSqlServer"].ConnectionString;
Response.Write("LocalSqlServer连接字符串:" + conn1 + "<br>");
string conn2 = ConfigurationManager.ConnectionStrings["SQL2000"].ConnectionString;
Response.Write("SQL2000连接字符串:" + conn2+ "<br>");
string conn3 = ConfigurationManager.ConnectionStrings["SQLExpress"].ConnectionString;
Response.Write("SQLEXPRESS连接字符串:" + conn3 + "<br>");
读取<appSettings>区块连接字符串设置值
string txtCompany = ConfigurationManager.AppSettings["Company"];
Response.Write("公司名称:" + txtCompany + "<br>");
string txtServiceTel = ConfigurationManager.AppSettings["Service TEL"];
Response.Write("客服电话:" + ConfigurationManager.AppSettings["Service Tel"] + "<br>");
读取<mailSettings>区块连接字符串设置值
//打开Request所在路径网站的Web.config文件
Configuration config = ConfigurationManager.OpenWebConfiguration(this.Request.ApplicationPath);
//取得Web.config中Mail设定区块
MailSettingsSectionGroup netSmtpMailSection = (MailSettingsSectionGroup)config.GetSectionGroup
("system.net/mailSettings");
//读取显示mailSettingsx设定相关值
Response.Write("Mail主机名称:" + netSmtpMailSection.Smtp.Network.Host + "<BR>");
Response.Write("Mail主机Port:" + netSmtpMailSection.Smtp.Network.Port + "<BR>");
Response.Write("Mail信息:" + netSmtpMailSection.Smtp.From + "<BR>");
//如果Mail的Authentication验证模式选择Basic,则可读取UserName及Password
//Response.Write("用户名:" + netSmtpMailSection.Smtp.Network.UserName + "<BR>");
//Response.Write("用户密码:" + netSmtpMailSection.Smtp.Network.Password + "<BR>");
string conn1 = ConfigurationManager.ConnectionStrings["LocalSqlServer"].ConnectionString;
Response.Write("LocalSqlServer连接字符串:" + conn1 + "<br>");
string conn2 = ConfigurationManager.ConnectionStrings["SQL2000"].ConnectionString;
Response.Write("SQL2000连接字符串:" + conn2+ "<br>");
string conn3 = ConfigurationManager.ConnectionStrings["SQLExpress"].ConnectionString;
Response.Write("SQLEXPRESS连接字符串:" + conn3 + "<br>");
读取<appSettings>区块连接字符串设置值
string txtCompany = ConfigurationManager.AppSettings["Company"];
Response.Write("公司名称:" + txtCompany + "<br>");
string txtServiceTel = ConfigurationManager.AppSettings["Service TEL"];
Response.Write("客服电话:" + ConfigurationManager.AppSettings["Service Tel"] + "<br>");
读取<mailSettings>区块连接字符串设置值
//打开Request所在路径网站的Web.config文件
Configuration config = ConfigurationManager.OpenWebConfiguration(this.Request.ApplicationPath);
//取得Web.config中Mail设定区块
MailSettingsSectionGroup netSmtpMailSection = (MailSettingsSectionGroup)config.GetSectionGroup
("system.net/mailSettings");
//读取显示mailSettingsx设定相关值
Response.Write("Mail主机名称:" + netSmtpMailSection.Smtp.Network.Host + "<BR>");
Response.Write("Mail主机Port:" + netSmtpMailSection.Smtp.Network.Port + "<BR>");
Response.Write("Mail信息:" + netSmtpMailSection.Smtp.From + "<BR>");
//如果Mail的Authentication验证模式选择Basic,则可读取UserName及Password
//Response.Write("用户名:" + netSmtpMailSection.Smtp.Network.UserName + "<BR>");
//Response.Write("用户密码:" + netSmtpMailSection.Smtp.Network.Password + "<BR>");
相关文章推荐
- Access数据库连接字符串读取,设置
- 怎样从ASP.NET2.0中读取连接字符串的设置
- ASP.NET数据库连接字符串的设置与读取
- C# 多种方法读取和设置连接字符串
- 怎样从ASP.NET 2.0中读取连接字符串的设置
- C# 多种方法读取和设置连接字符串
- 数据库连接字符串的设置与读取
- 怎样从web.config中读取连接字符串的设置
- 怎样从ASP.NET2.0中读取连接字符串的设置
- 怎样从ASP.NET 2.0中读取连接字符串的设置新增方法
- 使用OLEDB读取不同版本Excel数据的连接字符串设置
- 怎样从ASP.NET 2.0中读取连接字符串的设置
- 怎样从ASP.NET 2.0中读取连接字符串的设置
- 怎样从ASP.NET 2.0中读取连接字符串的设置
- 使用OLEDB读取不同版本Excel数据的连接字符串设置
- C# 多种方法读取和设置连接字符串
- 使用OLEDB读取不同版本Excel数据的连接字符串设置
- 使用OLEDB读取不同版本Excel数据的连接字符串设置
- 怎样从ASP.NET 2.0中读取连接字符串的设置
- EF+Sqlite 动态设置连接字符串