public void Conectar(eBanco v_iBanco, string v_sConnectionString) { try { this.eEnumeradorSelecao = v_iBanco; Dor.Util.UtDbNet.ConfigurarIdentificadorEnumeradorBancoDados(this.eEnumeradorSelecao); m_oConexao = ObterConexao(v_iBanco); if (!(this.Conexao.State == ConnectionState.Open)) { m_oConexao.ConnectionString = v_sConnectionString; m_oConexao.Open(); } } catch (Exception ex) { throw new ConexaoInvalida(ex.Message); } }
private IDbConnection ObterConexao() { eBanco EnumeradorSelecao = (eBanco)Enum.Parse(typeof(eBanco), Dor.Util.UtConfiguracao.lerParametro("banco")); this.eEnumeradorSelecao = EnumeradorSelecao; Dor.Util.UtDbNet.ConfigurarIdentificadorEnumeradorBancoDados(this.eEnumeradorSelecao); return ObterConexao(EnumeradorSelecao); }
private IDbConnection ObterConexao(eBanco v_iBanco) { this.eEnumeradorSelecao = v_iBanco; object oRetorno = null; switch (this.eEnumeradorSelecao) { case eBanco.access: this.m_sDescricaoBanco = "access"; oRetorno = new System.Data.OleDb.OleDbConnection(); break; case eBanco.mysql: this.m_sDescricaoBanco = "mysql"; oRetorno = new MySqlConnection(); break; case eBanco.oracle: this.m_sDescricaoBanco = "oracle"; oRetorno = new OracleConnection(); break; case eBanco.informix: this.m_sDescricaoBanco = "informix"; // oRetorno = new IBM.Data.Informix.IfxConnection(); break; case eBanco.sqlserver: this.m_sDescricaoBanco = "sqlserver"; oRetorno = new System.Data.SqlClient.SqlConnection(); break; } return (IDbConnection)oRetorno; }
public void ConfigurarEnumeradorChaveDesejada(string v_sChaveConfigBancoDados) { eBanco EnumeradorSelecao = Dor.Util.UtDbNet.ObterIdentificadorEnumeradorBancoDados(v_sChaveConfigBancoDados); if (EnumeradorSelecao != this.eEnumeradorSelecao) { this.eEnumeradorSelecao = EnumeradorSelecao; } }