读取连接字符串

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;

        }


你可能感兴趣的:(String,Class,数据库服务器)