/// <summary> /// get a data connection /// </summary> public CDataConnection GetDataConnection() { //get the connection string from the web.config file //connection string is encrypted in the file using MS recommended procedures // //cd\ //cd windows //cd microsoft.net //cd framework //cd v2.0.50727 //aspnet_regiis -pe "connectionStrings" -app "/PrimeCarePlus" -prov "RsaProtectedConfigurationProvider" // //look for connection strings in connection strings and app settings string strConnectionString = ""; try { //try to get the connection string from the encrypted connectionstrings section strConnectionString = ConfigurationManager.ConnectionStrings["DBConnString"].ConnectionString; } catch (Exception eee) { //pull from appsettings if failed, this lets developers connect from local boxes. //strConnectionString = System.Configuration.ConfigurationManager.AppSettings["DBConnString"]; string strStatus = eee.Message; } bool bAudit = false; string strAudit = ""; if (System.Configuration.ConfigurationManager.AppSettings["AUDIT"] != null) { strAudit = System.Configuration.ConfigurationManager.AppSettings["AUDIT"].ToString(); if (strAudit == "1") { bAudit = true; } } CDataConnection DBConnection; //create a new dataconnection object DBConnection = new CDataConnection(); //Connect to the database, connection is housed in the master page //so that all pages that use the master have access to it. if (!DBConnection.Connect(strConnectionString, (int)DataConnectionType.Oracle, bAudit)) { return(null); } return(DBConnection); }
/// <summary> /// connect to datasource /// </summary> private bool ConnectToDataSource() { //get the connection string from the web.config file //connection string is encrypted in the file using MS recommended procedures // //cd\ //cd windows //cd microsoft.net //cd framework //cd v2.0.50727 //aspnet_regiis -pe "connectionStrings" -app "/PrimeCarePlus" -prov "RsaProtectedConfigurationProvider" // //look for connection strings in connection strings and app settings string strConnectionString = string.Empty; try { //try to get the connection string from the encrypted connectionstrings section strConnectionString = ConfigurationManager.ConnectionStrings["DBConnString"].ConnectionString; Key = ConfigurationManager.ConnectionStrings["Key"].ConnectionString; } catch (Exception e) { string strStatus = e.Message; } bool bAudit = (ConfigurationManager.AppSettings["AUDIT"] == "1") ? true : false; //Connect to the database, connection is housed in the master page //so that all pages that use the master have access to it. if (!m_DBConnection.Connect( strConnectionString, (int)DataConnectionType.Oracle, bAudit)) { Session["DB_ERROR_CODE"] = string.Empty; Session["DB_ERROR"] = string.Empty; m_strStatusComment = "Error Connecting to Data Source"; m_lStatusCode = 1; return(false); } return(true); }