public IDbConnection OpenConnection(string database) { //dbRoot mymeta = new dbRoot(); dbRoot mymeta = CurrentDbRoot(); IDbConnection _connection = null; try { // special code to handle databases that cannot have multiple open connections. object v = mymeta.PluginSpecificData(DbDriver, "requiresinternalconnection"); if (v != null && v.GetType() == typeof(bool)) { if ((bool)v) { _connection = mymeta.PluginSpecificData(DbDriver, "internalconnection") as IDbConnection; } } // The standard connection code. if (_connection == null) { _connection = mymeta.BuildConnection(DbDriver, ConnectionString); } if (_connection != null) { if (_connection.State != ConnectionState.Open) { _connection.Open(); } if (!string.IsNullOrEmpty(database)) { mymeta.ChangeDatabase(_connection, database); } } } catch (Exception ex) { this._mdi.ErrorList.AddErrors(ex); } return(_connection); }
private void _ProcessMyMeta() { if (_argmgr.MergeMetaFiles) { try { dbRoot.MergeUserMetaDataFiles(_argmgr.MetaFile1, _argmgr.MetaDatabase1, _argmgr.MetaFile2, _argmgr.MetaDatabase2, _argmgr.MetaFileMerged); } catch (Exception ex) { this._log.Write(ex); this._log.Write("Merge UserMetaData files failed."); } } else { IDbConnection connection = null; try { dbRoot mymeta = new dbRoot(); connection = mymeta.BuildConnection(_argmgr.ConnectionType, _argmgr.ConnectionString); _log.Write("Beginning test for {0}: {1}", connection.GetType().ToString(), _argmgr.ConnectionString); connection.Open(); connection.Close(); _log.Write("Test Successful"); } catch (Exception ex) { _log.Write("Test Failed"); if (_log != null) { _log.Write(ex); } _returnValue = -1; } if (connection != null) { connection.Close(); connection = null; } } }