/// <summary> /// mehod to open the connection to the data base /// </summary> public void Open() { try { // calling method from DBManagerFactory class to get the provider type connection object idbConnection = DBManagerFactory.GetConnection(this.providerType); // passing connection string idbConnection.ConnectionString = this.ConnectionString; if (idbConnection.State == ConnectionState.Open) { idbConnection.Close(); } // chek for open connection state if (idbConnection.State != ConnectionState.Open) { idbConnection.Open(); } // calling method from DBManagerFactory class to get the provider type command object this.idbCommand = DBManagerFactory.GetCommand(this.ProviderType); this.idbTransaction = DBManagerFactory.GetTransaction(idbConnection, this.ProviderType); } catch (Exception ex) { throw ex; } }
/// <summary> /// method to begin the transaction /// </summary> public void BeginTransaction() { try { if (this.idbTransaction == null) { // calling method from DBManagerFactory to open the transaction of specific provider idbTransaction = DBManagerFactory.GetTransaction(this.idbConnection, this.ProviderType); } // assign the transaction to the command object this.idbCommand.Transaction = idbTransaction; } catch (Exception ex) { throw ex; } }