private void InitClass() { // create all the objects and initialize other members. m_scoMainConnection = new SqlConnection(); m_bMainConnectionIsCreatedLocal = true; m_cpMainConnectionProvider = null; AppSettingsReader m_asrConfigReader = new AppSettingsReader(); // Set connection string of the sqlconnection object m_scoMainConnection.ConnectionString = m_asrConfigReader.GetValue("Main.ConnectionString", typeof(string)).ToString(); m_bIsDisposed = false; }
protected virtual void Dispose(bool bIsDisposing) { // Check to see if Dispose has already been called. if (!m_bIsDisposed) { if (bIsDisposing) { // Dispose managed resources. if (m_bMainConnectionIsCreatedLocal) { // Object is created in this class, so destroy it here. m_scoMainConnection.Close(); m_scoMainConnection.Dispose(); m_bMainConnectionIsCreatedLocal = false; } m_cpMainConnectionProvider = null; m_scoMainConnection = null; } } m_bIsDisposed = true; }