System.Data.Common.DbConnection.Open()

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 7

1. Example

Project: DotNetSiemensPLCToolBoxLibrary
Source File: MsSQLStorage.cs
public 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;
            }
        }

2. Example

Project: DotNetSiemensPLCToolBoxLibrary
Source File: MsSQLStorage.cs
private void CheckAndEstablishReadConnection()
        {
            if (readDBConn == null)
            {
                readDBConn = new SqlConnection(ConnectionString);
                readDBConn.Open();
            }
        }

3. Example

Project: DotNetSiemensPLCToolBoxLibrary
Source File: MySQLStorage.cs
public 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;
            }
        }

4. Example

Project: DotNetSiemensPLCToolBoxLibrary
Source File: PostgreSQLStorage.cs
public 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;
            }
        }

5. Example

Project: DotNetSiemensPLCToolBoxLibrary
Source File: SQLLiteStorage.cs
private void CheckAndEstablishReadConnection()
        {
            if (readDBConn == null)
            {
                readDBConn = new SQLiteConnection(ConnectionString);
                readDBConn.Open();
            } 
        }

6. Example

Project: nesper
Source File: DbDriverODBC.cs
public override DbConnection CreateConnection()
        {
            DbConnection dbConnection = new OdbcConnection(ConnectionString);
            dbConnection.Open();
            return dbConnection;
        }

7. Example

Project: nesper
Source File: DbDriverSqlServer.cs
public override DbConnection CreateConnection()
        {
            DbConnection dbConnection = new SqlConnection(ConnectionString);
            dbConnection.Open();
            return dbConnection;
        }

8. Example

Project: fluentmigrator
Source File: SQLiteSchemaDumpTests.cs
[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();
        }

9. Example

Project: RawDataAccessBencher
Source File: L2SBencherDataContext.cs
private 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;
		}

10. Example

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

11. Example

Project: efprs
Source File: UnitOfWork.cs
private void OpenConnection()
        {
            if (((IObjectContextAdapter)_dbContext).ObjectContext.Connection.State != ConnectionState.Open)
            {
                ((IObjectContextAdapter)_dbContext).ObjectContext.Connection.Open();
            }
        }

12. Example

Project: efprs
Source File: UnitOfWork.cs
private void OpenConnection()
        {
            if (_objectContext.Connection.State != ConnectionState.Open)
            {
                _objectContext.Connection.Open();
            }
        }

13. Example

Project: efprs
Source File: UnitOfWork.cs
private void OpenConnection()
        {
            if (((IObjectContextAdapter)_dbContext).ObjectContext.Connection.State != ConnectionState.Open)
            {
                ((IObjectContextAdapter)_dbContext).ObjectContext.Connection.Open();
            }
        }

14. Example

Project: Craig-s-Utility-Library
Source File: DbCommandExtensions.cs
public static DbCommand Open(this DbCommand Command)
        {
            if (Command != null
                && Command.Connection != null
                && Command.Connection.State != ConnectionState.Open)
                Command.Connection.Open();
            return Command;
        }

15. Example

Project: Craig-s-Utility-Library
Source File: DbCommandExtensions.cs
public static DbCommand Open(this DbCommand Command)
        {
            if (Command != null
                && Command.Connection != null
                && Command.Connection.State != ConnectionState.Open)
                Command.Connection.Open();
            return Command;
        }

16. Example

Project: Sequelocity.NET
Source File: SequelocityDotNet.cs
public static DbCommand OpenConnection( this DbCommand dbCommand )
        {
            if ( dbCommand.Connection.State != ConnectionState.Open )
            {
                dbCommand.Connection.Open();
            }

            return dbCommand;
        }

17. Example

Project: ActivityManager
Source File: SqlDataSource.cs
public void SqlOpenConnection()
        {
            if (connection.State == System.Data.ConnectionState.Closed)
                connection.Open();
            permanent_connection = true;
        }

18. Example

Project: dotnetmigrations
Source File: DataAccess.cs
public void OpenConnection()
        {
            _connection.Open();
        }

19. Example

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

20. Example

Project: referencesource
Source File: DBConnection.cs
public 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;
        }

21. Example

Project: SQLiteCodeFirst
Source File: MemoryDbTest.cs
[TestMethod]
        public void CreateInMemoryDatabaseTest()
        {
            using (DbConnect/n ..... /n //View Source file for more details /n }

22. Example

Project: ArcBruTile
Source File: DbCache.cs
private bool OpenConnectionIfClosed()
        {
            if (Connection.State != ConnectionState.Open)
            {
                Connection.Open();
                return true;
            }
            return false;
        }

23. Example

Project: VoxelSim
Source File: BasicDataServiceTest.cs
protected virtual DbConnection Connect()
        {
            DbConnection cnn = new TConn();
            cnn.ConnectionString = m_connStr;
            cnn.Open();
            return cnn;
        }

24. Example

Project: opensimulator
Source File: BasicDataServiceTest.cs
protected virtual DbConnection Connect()
        {
            DbConnection cnn = new TConn();
            cnn.ConnectionString = m_connStr;
            cnn.Open();
            return cnn;
        }

25. Example

Project: NServiceKit
Source File: ProfiledDbConnection.cs
public override void Open()
        {
            if (_conn.State != ConnectionState.Open)
                _conn.Open();
        }

26. Example

Project: initialround
Source File: DataController.cs
public static Models.Contexts.DbContext CreateDbContext(string connectionString)
        {
            Models.Contexts.DbContext context = new Models.Contexts.DbContext(connectionString);

            ((IObjectContextAdapter)context).ObjectContext.Connection.Open();

            return context;
        }

27. Example

Project: Susanoo
Source File: DatabaseManager.cs
protected virtual void OpenConnectionInternal()
        {
            if (Connection.State != ConnectionState.Open)
                Connection.Open();
        }

28. Example

Project: Radical
Source File: DbConnectionWrapper.cs
public override void Open()
        {
            if( this.WrappedConnection.State == ConnectionState.Closed )
            {
                this.WrappedConnection.Open();
            }
        }

29. Example

Project: framework
Source File: Transaction.cs
public void Start()
            {
                if (!Started)
                {
                    Connection = Connector.Current.CreateConnection();

                    Connection.Open();
                    //Transaction = Connection.BeginTransaction(IsolationLevel ?? con.IsolationLevel);
                    Started = true;
                }
            }

30. Example

Project: SubSonic-2.0
Source File: SubSonicRepository.cs
public bool IsOnline() {
            bool result = false;

            using(DbConnection conn=this.Provider.CreateConnection()){
                try {
                    conn.Open();
                    result = true;
                } catch {
                    result = false;
                }
            }
            return true;
        }

31. Example

Project: SubSonic-2.0
Source File: SubSonicRepository.cs
public bool IsOnline(string connectionString) {
            bool result = false;

            using (DbConnection conn = this.Provider.CreateConnection(connectionString)) {
                try {
                    conn.Open();
                    result = true;
                } catch {
                    result = false;
                }
            }
            return true;
        }

32. Example

Project: DNTProfiler
Source File: ProfiledDbConnection.cs
public override void Open()
        {
            _profiler.ConnectionOpened(InnerConnection, NHProfilerContextProvider.GetLoggedDbConnection(InnerConnection));
            InnerConnection.Open();
        }

33. Example

Project: Glimpse.Nancy
Source File: ConnectionManager.cs
public IDbConnection GetConnection()
        {
            var conn = this.factory.CreateConnection();
            conn.ConnectionString = @"Data Source=" + this.databaseName;
            conn.Open();
            return conn;
        }

34. Example

Project: InvokeQueryPowershellModule
Source File: InvokeQueryBase.cs
protected 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;
        }

35. Example

Project: Wexflow
Source File: Sql.cs
void ExecSql(DbConnection conn, DbCommand comm)
        {
            conn.Open();
            comm.ExecuteNonQuery();
        }

36. Example

Project: DotNetSiemensPLCToolBoxLibrary
Source File: MySQLStorage.cs
private void CheckAndEstablishReadConnection()
        {
            if (readDBConn == null)
            {
                readDBConn = new MySqlConnection(ConnectionString);
                readDBConn.Open();
                readDBConn.ChangeDatabase(myConfig.Database);
            } 
        }

37. Example

Project: DotNetSiemensPLCToolBoxLibrary
Source File: PostgreSQLStorage.cs
private void CheckAndEstablishReadConnection()
        {
            if (readDBConn == null)
            {
                readDBConn = new NpgsqlConnection(ConnectionString);
                readDBConn.Open();
                readDBConn.ChangeDatabase(myConfig.Database);
            } 
        }

38. Example

Project: EDDiscovery
Source File: SQLiteConnectionED.cs
private 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;
        }

39. Example

Project: nesper
Source File: DbDriverGeneric.cs
public 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);
            }
        }

40. Example

Project: nesper
Source File: DbDriverMySQL.cs
public override DbConnection CreateConnection()
        {
            DbConnection dbConnection = dbProviderFactory.CreateConnection();
            dbConnection.ConnectionString = ConnectionString;
            dbConnection.Open();
            return dbConnection;
        }

41. Example

Project: nesper
Source File: DbDriverGeneric.cs
public 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);
            }
        }

42. Example

Project: nesper
Source File: DbDriverMySQL.cs
public override DbConnection CreateConnection()
        {
            DbConnection dbConnection = dbProviderFactory.CreateConnection();
            dbConnection.ConnectionString = ConnectionString;
            dbConnection.Open();
            return dbConnection;
        }

43. Example

Project: PeanutButter
Source File: TempDB.cs
private 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");
        }

44. Example

Project: RawDataAccessBencher
Source File: Massive.cs
public virtual DbConnection OpenConnection()
        {
            var result = _factory.CreateConnection();
            result.ConnectionString = ConnectionProfile.ConnectionString;
            result.Open();
            return result;
        }

45. Example

Project: RawDataAccessBencher
Source File: Massive.cs
public virtual DbConnection OpenConnection()
		{
			var result = _factory.CreateConnection();
			result.ConnectionString = ConnectionString;
			result.Open();
			return result;
		}

46. Example

Project: WPFCrudControl
Source File: UnitOfWork.cs
public void BeginTransaction(IsolationLevel isolationLevel = IsolationLevel.Unspecified)
        {
            _objectContext = ((IObjectContextAdapter)_dataContext).ObjectContext;
            if (_objectContext.Connection.State != ConnectionState.Open)
            {
                _objectContext.Connection.Open();
            }

            _transaction = _objectContext.Connection.BeginTransaction(isolationLevel);
        }

47. Example

Project: EntityFramework.CommonTools
Source File: TestInitializer.cs
[TestInitialize]
        public void TestInitialize()
        {
            _connection = new SQLite/n ..... /n //View Source file for more details /n }

48. Example

Project: Sequelocity.NET
Source File: SequelocityDotNet.cs
public static bool TestConnection( this DatabaseCommand databaseCommand )
        {
            try
            {
                databaseCommand.DbCommand.Connection.Open();

                databaseCommand.DbCommand.Connection.Close();

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

49. Example

Project: URF
Source File: UnitOfWork.cs
public 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);
        }

50. Example

Project: Lidarr
Source File: DataMapper.cs
protected internal void OpenConnection()
        {
            OnOpeningConnection();

            if (Command.Connection.State != ConnectionState.Open)
                Command.Connection.Open();
        }