读取连接字符串
2012-09-24 17:52
120 查看
using System.Configuration; this.cboxConn.Text.Trim() /// string getValue class DbConnection { private static string currentConnectionString = ConfigurationManager.ConnectionStrings["SalaryManager.Properties.Settings.severConnection"].ConnectionString; private static string loginConnectionStr = "数据库服务器"; public static string returnConnectionStr() { return loginConnectionStr; } public static string isServerConnection(string getValue ) { if (getValue == "数据库服务器") { currentConnectionString = ConfigurationManager.ConnectionStrings["SalaryManager.Properties.Settings.severConnection"].ConnectionString; } else { currentConnectionString = ConfigurationManager.ConnectionStrings["SalaryManager.Properties.Settings.localConnection"].ConnectionString; } loginConnectionStr = getValue; return currentConnectionString; } public static SqlConnection createConn() { SqlConnection thisConnection = new SqlConnection(currentConnectionString); return thisConnection; }
相关文章推荐
- 在三层开发的DAL层中, 从web.config中读取数据库的连接字符串的方法
- [导入].NET中使用三层构架如何从DAL层读取web.config中的数据库连接字符串!
- 读取连接字符串
- 怎样从ASP.NET 2.0中读取连接字符串的设置
- 从Web.config 文件读取连接字符串
- MSDN上关于读取连接字符串的例子。
- C# 多种方法读取和设置连接字符串
- 无法读取连接字符串,配置文件有错。
- linux shell 字符串操作详解 (长度,读取,替换,截取,连接,对比,删除,位置 )
- WebService如何从Web.Config中读取数据库连接字符串
- 读取web.config中连接字符串的方法
- Access数据库连接字符串读取,设置
- 从Web.config文件中读取连接字符串的两种方法
- asp.net2.0中读取web.config数据库连接字符串2种方法
- asp.net2.0中读取web.config数据库连接字符串2种方法
- linux shell 字符串操作详解 (长度,读取,替换,截取,连接,对比,删除,位置 )
- cs中读取web.config中的数据库连接字符串(两种)
- 怎样从ASP.NET 2.0中读取连接字符串的设置
- ORM读取web.config中的数据库连接字符串
- 使用OLEDB读取不同版本Excel数据的连接字符串设置