/// <summary> /// Execute a OracleCommand (that returns a resultset) against the specified OracleConnection /// using the provided parameters. /// </summary> /// <res> /// e.g.: /// DataSet ds = ExecuteDataset(conn, CommandType.StoredProcedure, "GetOrders", new OracleParameter("@prodid", 24)); /// </res> /// <param name="connection">a valid OracleConnection</param> /// <param name="commandType">the CommandType (stored procedure, text, etc.)</param> /// <param name="commandText">the stored procedure name or PL/SQL command</param> /// <param name="commandParameters">an array of SqlParamters used to execute the command</param> /// <returns>a dataset containing the resultset generated by the command</returns> public static DataSet ExecuteDataset(OracleConnection connection, CommandType commandType, string commandText, params OracleParameter[] commandParameters) { //create a command and prepare it for execution OracleCommand cmd = new OracleCommand(); PrepareCommand(cmd, connection, (OracleTransaction)null, commandType, commandText, commandParameters); //create the DataAdapter & DataSet OracleDataAdapter da = new OracleDataAdapter(cmd); DataSet ds = new DataSet(); //fill the DataSet using default values for DataTable names, etc. da.Fill(ds); // detach the OracleParameters from the command object, so they can be used again. cmd.Parameters.Clear(); //return the dataset return ds; }
/// Execute a OracleCommand (that returns a resultset) against the specified OracleConnection
/// using the provided parameters.
/// </summary>
/// <res>
/// e.g.:
/// DataSet ds = ExecuteDataset(conn, CommandType.StoredProcedure, "GetOrders", new OracleParameter("@prodid", 24));
/// </res>
/// <param name="connection">a valid OracleConnection</param>
/// <param name="commandType">the CommandType (stored procedure, text, etc.)</param>
/// <param name="commandText">the stored procedure name or PL/SQL command</param>
/// <param name="commandParameters">an array of SqlParamters used to execute the command</param>
/// <returns>a dataset containing the resultset generated by the command</returns>
public static DataSet ExecuteDataset(OracleConnection connection, CommandType commandType, string commandText, params OracleParameter[] commandParameters)
{
//create a command and prepare it for execution
OracleCommand cmd = new OracleCommand();
PrepareCommand(cmd, connection, (OracleTransaction)null, commandType, commandText, commandParameters); //create the DataAdapter & DataSet
OracleDataAdapter da = new OracleDataAdapter(cmd);
DataSet ds = new DataSet(); //fill the DataSet using default values for DataTable names, etc.
da.Fill(ds); // detach the OracleParameters from the command object, so they can be used again.
cmd.Parameters.Clear(); //return the dataset
return ds;
}