/// <summary> /// SQL Executer with return values /// </summary> /// <param name="sSQL"></param> /// <param name="iRetVal"></param> /// <returns></returns> private DataSet ExecuteSQLStatement(string sSQL, ref int iRetVal) { try { DataSet ds = new DataSet(); using (OleDbConnection conn = new OleDbConnection(ClsQuery.getConnString())) { using (OleDbDataAdapter adapter = new OleDbDataAdapter()) { //Open Connection conn.Open(); adapter.SelectCommand = new OleDbCommand(sSQL, conn); adapter.SelectCommand.CommandTimeout = 0; //Fill dataset adapter.Fill(ds); } } iRetVal = ds.Tables[0].Rows.Count; return(ds); } catch (Exception ex) { throw new Exception(ex.Message); } }
/// <summary> /// SQL executer with no expected return values /// </summary> /// <param name="sSQL"></param> /// <returns></returns> private int ExecuteNonQuery(string sSQL) { try { int iNumRows; using (OleDbConnection conn = new OleDbConnection(ClsQuery.getConnString())) { conn.Open(); OleDbCommand cmd = new OleDbCommand(sSQL, conn); cmd.CommandTimeout = 0; iNumRows = cmd.ExecuteNonQuery(); } return(iNumRows); } catch (Exception ex) { throw new Exception(ex.Message); } }