public MDBCommand(string cmdText, MDBConnection m_mdbCnn) { try { #if POSTGRESQL cmdText = cmdText.Replace("to_date", "to_timestamp"); this.commandText = cmdText; this.cnn = m_mdbCnn.con; this.cmd = new NpgsqlCommand(this.commandText, m_mdbCnn.con); this.cmd.CommandType = CommandType.Text; this.cmd.CommandTimeout = 30; #elif ORACLE string s_Text = cmdText.Trim().Trim(';'); s_Text = s_Text.Trim('\n'); s_Text = s_Text.Trim('\r'); s_Text = s_Text.Trim('\n'); s_Text = s_Text.Trim(';'); string[] sText = s_Text.Split(';'); if (sText.Length > 1) { cmdText = "begin\n" + s_Text + ";\n" + "end;\n"; } else { cmdText = s_Text; } this.commandText = cmdText; this.cnn = m_mdbCnn.con; this.cmd = new OracleCommand(this.commandText, m_mdbCnn.con); this.cmd.CommandType = CommandType.Text; this.cmd.CommandTimeout = 30; #elif SQLSERVER this.commandText = cmdText; this.cnn = m_mdbCnn.con; this.cmd = new SqlCommand(this.commandText, m_mdbCnn.con); this.cmd.CommandType = CommandType.Text; this.cmd.CommandTimeout = 30; #endif } catch (Exception exception) { #if POSTGRESQL throw new MDBException(exception, exception.Message); #elif ORACLE OracleException ex = exception as OracleException; throw new MDBException(exception, this.commandText, ex.Number); #elif SQLSERVER throw new MDBException(exception, exception.Message); #endif } }
public MDBDataAdapter(string cmdText, MDBConnection m_mdbCon) { this.mdbCon = m_mdbCon.con; try { #if POSTGRESQL this.adapter = new NpgsqlDataAdapter(cmdText, this.mdbCon); #else this.adapter = new OracleDataAdapter(cmdText, this.mdbCon); #endif } catch (Exception exception) { #if POSTGRESQL throw new MDBException(exception, exception.Message); #else OracleException ex = (OracleException)exception; throw new MDBException(exception, exception.Message, ex.Number); #endif } }