Here are the examples of the csharp api class System.Data.Common.DbConnection.Open() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
200 Examples
0
1. Example
View licensepublic override void Connect_To_Database(StorageConfig config) { myConfig = config as MsSQLConfig; if (myConfig == null) throw new Exception("Database Config is NULL"); try { myDBConn = new SqlConnection(ConnectionString); myDBConn.Open(); if (myDBConn.State != System.Data.ConnectionState.Open) throw new Exception("Unable to Open Database. Storage:" + config.Name); } catch (SqlException ex) { throw ex; } catch (Exception ex) { throw ex; } }
0
2. Example
View licenseprivate void CheckAndEstablishReadConnection() { if (readDBConn == null) { readDBConn = new SqlConnection(ConnectionString); readDBConn.Open(); } }
0
3. Example
View licensepublic override void Connect_To_Database(StorageConfig config) { myConfig = config as MySQLConfig; if (myConfig == null) throw new Exception("Database Config is NULL"); try { myDBConn = new MySqlConnection(ConnectionString); myDBConn.Open(); if (myDBConn.State != System.Data.ConnectionState.Open) throw new Exception("Unable to Open Database. Storage:" + config.Name); } catch (Exception ex) { throw ex; } }
0
4. Example
View licensepublic override void Connect_To_Database(StorageConfig config) { myConfig = config as PostgreSQLConfig; if (myConfig == null) throw new Exception("Database Config is NULL"); try { myDBConn = new Npgsql.NpgsqlConnection(ConnectionString); myDBConn.Open(); if (myDBConn.State != System.Data.ConnectionState.Open) throw new Exception("Unable to Open Database. Storage:" + config.Name); } catch (Exception ex) { throw ex; } }
0
5. Example
View licenseprivate void CheckAndEstablishReadConnection() { if (readDBConn == null) { readDBConn = new SQLiteConnection(ConnectionString); readDBConn.Open(); } }
0
6. Example
View licensepublic override DbConnection CreateConnection() { DbConnection dbConnection = new OdbcConnection(ConnectionString); dbConnection.Open(); return dbConnection; }
0
7. Example
View licensepublic override DbConnection CreateConnection() { DbConnection dbConnection = new SqlConnection(ConnectionString); dbConnection.Open(); return dbConnection; }
0
8. Example
View license[SetUp] public void Setup() { Connection = new SQLiteConnection(IntegrationTestOptions.SqlLite.ConnectionString); Processor = new SqliteProcessor(Connection, new SqliteGenerator(), new TextWriterAnnouncer(System.Console.Out), new ProcessorOptions(), new SqliteDbFactory()); SchemaDumper = new SqliteSchemaDumper(Processor, new TextWriterAnnouncer(System.Console.Out)); Connection.Open(); }
0
9. Example
View licenseprivate DbCommand SetupCommand(DbCommand toSetup, bool openConnection) { if(toSetup==null) { return toSetup; } toSetup.Connection = this.Connection; toSetup.Transaction = this.Transaction; toSetup.CommandTimeout = this.CommandTimeout; if((toSetup.Connection!=null) && openConnection && (toSetup.Connection.State!=ConnectionState.Open)) { toSetup.Connection.Open(); } return toSetup; }
0
0
11. Example
View licenseprivate void OpenConnection() { if (((IObjectContextAdapter)_dbContext).ObjectContext.Connection.State != ConnectionState.Open) { ((IObjectContextAdapter)_dbContext).ObjectContext.Connection.Open(); } }
0
12. Example
View licenseprivate void OpenConnection() { if (_objectContext.Connection.State != ConnectionState.Open) { _objectContext.Connection.Open(); } }
0
13. Example
View licenseprivate void OpenConnection() { if (((IObjectContextAdapter)_dbContext).ObjectContext.Connection.State != ConnectionState.Open) { ((IObjectContextAdapter)_dbContext).ObjectContext.Connection.Open(); } }
0
14. Example
View licensepublic static DbCommand Open(this DbCommand Command) { if (Command != null && Command.Connection != null && Command.Connection.State != ConnectionState.Open) Command.Connection.Open(); return Command; }
0
15. Example
View licensepublic static DbCommand Open(this DbCommand Command) { if (Command != null && Command.Connection != null && Command.Connection.State != ConnectionState.Open) Command.Connection.Open(); return Command; }
0
16. Example
View licensepublic static DbCommand OpenConnection( this DbCommand dbCommand ) { if ( dbCommand.Connection.State != ConnectionState.Open ) { dbCommand.Connection.Open(); } return dbCommand; }
0
17. Example
View licensepublic void SqlOpenConnection() { if (connection.State == System.Data.ConnectionState.Closed) connection.Open(); permanent_connection = true; }
0
0
0
20. Example
View licensepublic virtual Task OpenAsync(CancellationToken cancellationToken) { TaskCompletionSource<object> taskCompletionSource = new TaskCompletionSource<object>(); if (cancellationToken.IsCancellationRequested) { taskCompletionSource.SetCanceled(); } else { try { Open(); taskCompletionSource.SetResult(null); } catch (Exception e) { taskCompletionSource.SetException(e); } } return taskCompletionSource.Task; }
0
21. Example
View license[TestMethod] public void CreateInMemoryDatabaseTest() { using (DbConnect/n ..... /n //View Source file for more details /n }
0
22. Example
View licenseprivate bool OpenConnectionIfClosed() { if (Connection.State != ConnectionState.Open) { Connection.Open(); return true; } return false; }
0
23. Example
View licenseprotected virtual DbConnection Connect() { DbConnection cnn = new TConn(); cnn.ConnectionString = m_connStr; cnn.Open(); return cnn; }
0
24. Example
View licenseprotected virtual DbConnection Connect() { DbConnection cnn = new TConn(); cnn.ConnectionString = m_connStr; cnn.Open(); return cnn; }
0
25. Example
View licensepublic override void Open() { if (_conn.State != ConnectionState.Open) _conn.Open(); }
0
26. Example
View licensepublic static Models.Contexts.DbContext CreateDbContext(string connectionString) { Models.Contexts.DbContext context = new Models.Contexts.DbContext(connectionString); ((IObjectContextAdapter)context).ObjectContext.Connection.Open(); return context; }
0
27. Example
View licenseprotected virtual void OpenConnectionInternal() { if (Connection.State != ConnectionState.Open) Connection.Open(); }
0
28. Example
View licensepublic override void Open() { if( this.WrappedConnection.State == ConnectionState.Closed ) { this.WrappedConnection.Open(); } }
0
29. Example
View licensepublic void Start() { if (!Started) { Connection = Connector.Current.CreateConnection(); Connection.Open(); //Transaction = Connection.BeginTransaction(IsolationLevel ?? con.IsolationLevel); Started = true; } }
0
30. Example
View licensepublic bool IsOnline() { bool result = false; using(DbConnection conn=this.Provider.CreateConnection()){ try { conn.Open(); result = true; } catch { result = false; } } return true; }
0
31. Example
View licensepublic bool IsOnline(string connectionString) { bool result = false; using (DbConnection conn = this.Provider.CreateConnection(connectionString)) { try { conn.Open(); result = true; } catch { result = false; } } return true; }
0
32. Example
View licensepublic override void Open() { _profiler.ConnectionOpened(InnerConnection, NHProfilerContextProvider.GetLoggedDbConnection(InnerConnection)); InnerConnection.Open(); }
0
33. Example
View licensepublic IDbConnection GetConnection() { var conn = this.factory.CreateConnection(); conn.ConnectionString = @"Data Source=" + this.databaseName; conn.Open(); return conn; }
0
34. Example
View licenseprotected virtual DbConnection GetDbConnection() { var connection = ProviderFactory.CreateConnection(); if (connection == null) { throw new ApplicationException("Unable to create conneciton. Please make sure all DLL libraries have been installed."); } connection.ConnectionString = ConnectionString; connection.Open(); return connection; }
0
35. Example
View licensevoid ExecSql(DbConnection conn, DbCommand comm) { conn.Open(); comm.ExecuteNonQuery(); }
0
36. Example
View licenseprivate void CheckAndEstablishReadConnection() { if (readDBConn == null) { readDBConn = new MySqlConnection(ConnectionString); readDBConn.Open(); readDBConn.ChangeDatabase(myConfig.Database); } }
0
37. Example
View licenseprivate void CheckAndEstablishReadConnection() { if (readDBConn == null) { readDBConn = new NpgsqlConnection(ConnectionString); readDBConn.Open(); readDBConn.ChangeDatabase(myConfig.Database); } }
0
38. Example
View licenseprivate static bool DbFactoryWorks(DbProviderFactory factory) { if (factory != null) { try { using (var conn = factory.CreateConnection()) { conn.ConnectionString = "Data Source=:memory:;Pooling=true;"; conn.Open(); return true; } } catch { } } return false; }
0
39. Example
View licensepublic override DbConnection CreateConnection() { try { DbConnection dbConnection = dbProviderFactory.CreateConnection(); dbConnection.ConnectionString = ConnectionString; dbConnection.Open(); return dbConnection; } catch (DbException ex) { String detail = "DbException: " + ex.Message + " VendorError: " + ex.ErrorCode; throw new DatabaseConfigException( "Error obtaining database connection using connection-string '" + ConnectionString + "' with detail " + detail, ex); } }
0
40. Example
View licensepublic override DbConnection CreateConnection() { DbConnection dbConnection = dbProviderFactory.CreateConnection(); dbConnection.ConnectionString = ConnectionString; dbConnection.Open(); return dbConnection; }
0
41. Example
View licensepublic override DbConnection CreateConnection() { try { DbConnection dbConnection = dbProviderFactory.CreateConnection(); dbConnection.ConnectionString = ConnectionString; dbConnection.Open(); return dbConnection; } catch (DbException ex) { String detail = "DbException: " + ex.Message + " VendorError: " + ex.ErrorCode; throw new DatabaseConfigException( "Error obtaining database connection using connection-string '" + ConnectionString + "' with detail " + detail, ex); } }
0
42. Example
View licensepublic override DbConnection CreateConnection() { DbConnection dbConnection = dbProviderFactory.CreateConnection(); dbConnection.ConnectionString = ConnectionString; dbConnection.Open(); return dbConnection; }
0
43. Example
View licenseprivate DbConnection CreateOpenDatabaseConnection() { var connection = Activator.CreateInstance(typeof (TDatabaseConnection), ConnectionString) as DbConnection; if (connection != null) { connection.Open(); return connection; } else throw new InvalidOperationException($"Unable to instantate connection of type {typeof(TDatabaseConnection)} as a DbConnection"); }
0
44. Example
View licensepublic virtual DbConnection OpenConnection() { var result = _factory.CreateConnection(); result.ConnectionString = ConnectionProfile.ConnectionString; result.Open(); return result; }
0
45. Example
View licensepublic virtual DbConnection OpenConnection() { var result = _factory.CreateConnection(); result.ConnectionString = ConnectionString; result.Open(); return result; }
0
46. Example
View licensepublic void BeginTransaction(IsolationLevel isolationLevel = IsolationLevel.Unspecified) { _objectContext = ((IObjectContextAdapter)_dataContext).ObjectContext; if (_objectContext.Connection.State != ConnectionState.Open) { _objectContext.Connection.Open(); } _transaction = _objectContext.Connection.BeginTransaction(isolationLevel); }
0
47. Example
View license[TestInitialize] public void TestInitialize() { _connection = new SQLite/n ..... /n //View Source file for more details /n }
0
48. Example
View licensepublic static bool TestConnection( this DatabaseCommand databaseCommand ) { try { databaseCommand.DbCommand.Connection.Open(); databaseCommand.DbCommand.Connection.Close(); return true; } catch ( Exception ) { return false; } }
0
49. Example
View licensepublic virtual void BeginTransaction(IsolationLevel isolationLevel = IsolationLevel.Unspecified) { var objectContext = ((IObjectContextAdapter) _context).ObjectContext; if (objectContext.Connection.State != ConnectionState.Open) { objectContext.Connection.Open(); } Transaction = objectContext.Connection.BeginTransaction(isolationLevel); }
0
50. Example
View licenseprotected internal void OpenConnection() { OnOpeningConnection(); if (Command.Connection.State != ConnectionState.Open) Command.Connection.Open(); }