System.Data.Common.DbConnection.Close()

Here are the examples of the csharp api class System.Data.Common.DbConnection.Close() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

200 Examples 7

1. Example

Project: OrigoDB
Source File: SqlJournalWriter.cs
View license
public void Dispose()
        {
            _connection.Close();
        }

2. Example

View license
public override void Close()
        {
            if (myThread != null)
                myThread.Abort();
            if (myDBConn != null)
                myDBConn.Close();
        }

3. Example

View license
public override void Close()
        {
            if (myThread != null)
                myThread.Abort();
            if (myDBConn != null)
                myDBConn.Close();
        }

4. Example

View license
public override void Close()
        {
            if (myThread != null)
                myThread.Abort();
            if (myDBConn != null)
                myDBConn.Close();
        }

5. Example

View license
public override void Close()
        {
            if (myThread != null)
                myThread.Abort();
            if (myDBConn != null)
                myDBConn.Close();
        }

6. Example

Project: WPFCrudControl
Source File: UnitOfWork.cs
View license
public virtual void Dispose(bool disposing)
        {
            if (_disposed)
                return;

            if (disposing)
            {
                // free other managed objects that implement
                // IDisposable only

                try
                {
                    if (_objectContext != null && _objectContext.Connection.State == ConnectionState.Open)
                    {
                        _objectContext.Connection.Close();
                    }
                }
                catch (ObjectDisposedException)
                {
                    // do nothing, the objectContext has already been disposed
                }

                if (_dataContext != null)
                {
                    _dataContext.Dispose();
                    _dataContext = null;
                }
            }

            // release any unmanaged objects
            // set the object references to null

            _disposed = true;
        }

7. Example

Project: FreeSCADA
Source File: DbReader.cs
View license
public void Close()
        {
            if (dbConnection != null)
            {
                dbConnection.Close();
                dbConnection = null;
                dbProviderFactory = null;
            }
        }

8. Example

Project: FreeSCADA
Source File: DbWriter.cs
View license
public void Close()
		{
			if (dbConnection != null)
			{
				dbConnection.Close();
				dbConnection = null;
				dbProviderFactory = null;
			}
		}

9. Example

Project: Glimpse
Source File: GlimpseDbConnection.cs
View license
public override void Close()
        {
            InnerConnection.Close(); 
        }

10. Example

View license
[TestCleanup]
        public void TestCleanup()
        {
            _connection.Close();
        }

11. Example

Project: efprs
Source File: DbContextManager.cs
View license
public static void CloseAllDbContexts()
        {
            foreach (DbContext ctx in _storage.GetAllDbContexts())
            {
                if (((IObjectContextAdapter)ctx).ObjectContext.Connection.State == System.Data.ConnectionState.Open)
                    ((IObjectContextAdapter)ctx).ObjectContext.Connection.Close();
            }
        }

12. Example

Project: efprs
Source File: ObjectContextManager.cs
View license
public static void CloseAllObjectContexts()
        {
            foreach (ObjectContext ctx in Storage.GetAllObjectContexts())
            {
                if (ctx.Connection.State == System.Data.ConnectionState.Open)
                    ctx.Connection.Close();
            }
        }

13. Example

Project: efprs
Source File: UseMyDbContextTest.cs
View license
[TestFixtureTearDown]
        public void TearDown()
        {
            if ((context != null) && (((IObjectContextAdapter)context).ObjectContext.Connection.State == System.Data.ConnectionState.Open))
            {
                ((IObjectContextAdapter)context).ObjectContext.Connection.Close();
                context = null;
            }
        }

14. Example

Project: efprs
Source File: WithoutStorageTest.cs
View license
[TestFixtureTearDown]
        public void TearDown()
        {
            if ((context != null) && (((IObjectContextAdapter)context).ObjectContext.Connection.State == System.Data.ConnectionState.Open))
            {
                ((IObjectContextAdapter)context).ObjectContext.Connection.Close();
                context = null;
            }
        }

15. Example

Project: efprs
Source File: WithoutStorageTest.cs
View license
[TestFixtureTearDown]
        public void TearDown()
        {
            if ((context != null) && (context.Connection.State == System.Data.ConnectionState.Open))
            {
                context.Connection.Close();
                context = null;
            }
        }

16. Example

Project: efprs
Source File: DbContextManager.cs
View license
public static void CloseAllDbContexts()
        {
            foreach (DbContext ctx in _storage.GetAllDbContexts())
            {
                if (((IObjectContextAdapter)ctx).ObjectContext.Connection.State == System.Data.ConnectionState.Open)
                    ((IObjectContextAdapter)ctx).ObjectContext.Connection.Close();
            }
        }

17. Example

Project: efprs
Source File: UseMyDbContextTest.cs
View license
[TestCleanup]
        public void TearDown()
        {
            if ((context != null) && (((IObjectContextAdapter)context).ObjectContext.Connection.State == System.Data.ConnectionState.Open))
            {
                ((IObjectContextAdapter)context).ObjectContext.Connection.Close();
                context = null;
            }
        }

18. Example

Project: efprs
Source File: WithoutStorageTest.cs
View license
[TestCleanup]
        public void TearDown()
        {
            if ((context != null) && (((IObjectContextAdapter)context).ObjectContext.Connection.State == System.Data.ConnectionState.Open))
            {
                ((IObjectContextAdapter)context).ObjectContext.Connection.Close();
                context = null;
            }
        }

19. Example

View license
public static DbCommand Close(this DbCommand Command)
        {
            if (Command != null
                && Command.Connection != null
                && Command.Connection.State != ConnectionState.Closed)
                Command.Connection.Close();
            return Command;
        }

20. Example

View license
public static DbCommand Close(this DbCommand Command)
        {
            if (Command != null
                && Command.Connection != null
                && Command.Connection.State != ConnectionState.Closed)
                Command.Connection.Close();
            return Command;
        }

21. Example

Project: ActivityManager
Source File: SqlDataSource.cs
View license
public void SqlCloseConnection()
        {
            connection.Close();
            permanent_connection = false;
        }

22. Example

Project: dotnetmigrations
Source File: DataAccess.cs
View license
public void CloseConnection()
        {
            _connection.Close();
        }

23. Example

Project: Restful
Source File: SessionProvider.cs
View license
protected virtual void Dispose( bool disposing )
        {
            if( this.disposed == false )
            {
                if( disposing )
                {
                    this.connection.Close();
                }
            }

            this.disposed = true;
        }

24. Example

Project: linq2db
Source File: RetryingDbConnection.cs
View license
public override void Close()
		{
			_connection.Close();
		}

25. Example

Project: ALinq
Source File: Connection.cs
View license
public override void Close()
        {
            source.Close();
        }

26. Example

Project: LimeBean
Source File: PgSqlConnectionFixture.cs
View license
public override void Dispose() {
            _serviceConnection.Close();
        }

27. Example

Project: Weed3
Source File: DbTran.cs
View license
internal void close(bool isQueue) {
            if (queue == null || isQueue) {
                if (connection != null) {
                    //connection.setAutoCommit(true);
                    connection.Close();
                    connection = null;
                }
            }
        }

28. Example

Project: Weed3
Source File: SQLer.cs
View license
private void tryClose() {
            try { if (reader != null) { reader.Close(); reader = null; } } catch (Exception ex) { WeedConfig.logException(null, ex); };
            try { if (conn != null) { conn.Close(); conn = null; } } catch (Exception ex) { WeedConfig.logException(null, ex); };
        }

29. Example

Project: Weed3
Source File: DbTran.cs
View license
internal void close(bool isQueue) {
            if (queue == null || isQueue) {
                if (connection != null) {
                    //connection.setAutoCommit(true);
                    connection.Close();
                    connection = null;
                }
            }
        }

30. Example

Project: Weed3
Source File: SQLer.cs
View license
private void tryClose() {
            try { if (reader != null) { reader.Close(); reader = null; } } catch (Exception ex) { WeedConfig.logException(null, ex); };
            try { if (conn != null) { conn.Close(); conn = null; } } catch (Exception ex) { WeedConfig.logException(null, ex); };
        }

31. Example

Project: NServiceKit
Source File: ProfiledDbConnection.cs
View license
public override void Close()
        {
            if (autoDisposeConnection)
                _conn.Close();
        }

32. Example

Project: nuodb-dotnet
Source File: SQLEditor.cs
View license
internal void Disconnect()
        {
            if (_connection.State == System.Data.ConnectionState.Open)
                _connection.Close();
            connectionStatus.Text = "Disconnected";
        }

33. Example

Project: Opserver
Source File: ExtensionMethods.Sql.cs
View license
public void Dispose()
            {
                var cn = _connection;
                _connection = null;
                try { cn?.Close(); }
                catch { /* throwing from Dispose() is so lame */ }
            }

34. Example

View license
protected void Dispose(bool disposing)
        {
            if (disposing)
            {
                // dispose managed resources
                Connection.Close();
            }
        }

35. Example

View license
public void KillConnection()
        {
            Connection.Close();
            Connection = null;
        }

36. Example

Project: Susanoo
Source File: DatabaseManager.cs
View license
public virtual void CloseConnection()
        {
            if (Connection.State != ConnectionState.Closed)
            {
                Connection.Close();
                _explicitlyOpened = false;
            }
        }

37. Example

Project: Radical
Source File: DbConnectionWrapper.cs
View license
public override void Close()
        {
            this.WrappedConnection.Close();
        }

38. Example

Project: scada
Source File: DataSource.cs
View license
public void Disconnect()
        {
            if (Connection != null)
                Connection.Close();
        }

39. Example

View license
public virtual void ReleaseConnection(DbConnection connection)
        {
            if (connection != null && connection.State == ConnectionState.Open)
            {
                try
                {
                    connection.Close();
                    _diagnosticService.Emit(new SQLEventBuilder(this, SQLEventType.ConnectionClosed)
                    {
                        ConnectionName = _connectionStringSettings.Name
                    }.Build());
                }
                catch (Exception ex)
                {
                    _diagnosticService.Emit(new SQLEventBuilder(this, SQLEventType.CommandError)
                    {
                        Detail = "Error closing connection",
                        ConnectionName = _connectionStringSettings.Name,
                        Exception = ex
                    }.Build());
                }
            }
        }

40. Example

View license
protected virtual void Dispose(bool disposing)
        {
            if (disposing)
            {
                try
                {
                    _connection.Close();
                }
                catch (Exception ex)
                {
                    _diagnosticService.Emit(new SQLEventBuilder(this, SQLEventType.CommandError)
                    {
                        Detail = "Error closing singleton connection",
                        ConnectionName = _connectionStringSettings.Name,
                        Exception = ex
                    }.Build());
                }
            }
        }

41. Example

Project: DNTProfiler
Source File: ProfiledDbConnection.cs
View license
public override void Close()
        {
            _profiler.ConnectionClosed(InnerConnection, NHProfilerContextProvider.GetLoggedDbConnection(InnerConnection));
            InnerConnection.Close();
        }

42. Example

Project: encog-dotnet-core
Source File: SQLCODEC.cs
View license
public void Close()
        {
            if (_connection != null)
            {
                _connection.Close();
            }
            if (_results != null)
            {
                _results.Close();
            }
        }

43. Example

Project: Dos.ORM
Source File: Database.cs
View license
public void CloseConnection(DbConnection conn)
        {
            if (conn != null && conn.State != ConnectionState.Closed)
                try
                {
                    conn.Close();
                    conn.Dispose();
                }
                catch
                {
                }
        }

44. Example

Project: Dos.ORM
Source File: Database.cs
View license
public void CloseConnection(DbConnection conn)
        {
            if (conn != null && conn.State != ConnectionState.Closed)
                try
                {
                    conn.Close();
                    conn.Dispose();
                }
                catch
                {
                }
        }

45. Example

Project: Dos.ORM
Source File: Database.cs
View license
public void CloseConnection(DbConnection conn)
        {
            if (conn != null && conn.State != ConnectionState.Closed)
                try
                {
                    conn.Close();
                    conn.Dispose();
                }
                catch
                {
                }
        }

46. Example

View license
public static bool TestConnection( this DatabaseCommand databaseCommand )
        {
            try
            {
                databaseCommand.DbCommand.Connection.Open();

                databaseCommand.DbCommand.Connection.Close();

                return true;
            }
            catch ( Exception )
            {
                return false;
            }
        }

47. Example

View license
public static void CloseAndDispose( this DbCommand dbCommand )
        {
            dbCommand.Connection.Close();

            dbCommand.Connection.Dispose();

            dbCommand.Dispose();
        }

48. Example

Project: Lidarr
Source File: DataMapper.cs
View license
public void RollBack()
        {
            try
            {
                if (Command.Transaction != null)
                    Command.Transaction.Rollback();
            }
            finally
            {
                Command.Connection.Close();
            }
        }

49. Example

Project: Lidarr
Source File: DataMapper.cs
View license
public void Commit()
        {
            try
            {
                if (Command.Transaction != null)
                    Command.Transaction.Commit();
            }
            finally
            {
                Command.Connection.Close();
            }
        }

50. Example

Project: ALinq
Source File: SqlConnectionManager.cs
View license
private void CloseConnection()
        {
            if ((connection != null) && (connection.State != ConnectionState.Closed))
            {
                connection.Close();
            }
            RemoveInfoMessageHandler();
            AutoClose = false;
        }