none
output parameters to dataset/datatable RRS feed

  • Question

  • Why on earth won't this work? I've dumbed everything down so that the code be simple.

    I want fill my dataset with my stored procedures output parameters.

    The MessageBox displays my output parameter properly. I've tried many different combinations. I don't get any error messages, just an empty dataset.

    /*****************************************/

    DataSet ds = new DataSet();

    OracleConnection conn = new OracleConnection("Data Source=database;User ID=username;Password=password");

    OracleCommand cmd = new OracleCommand("STOREDPROCEDURE", conn);

    OracleParameter par;

    OracleDataAdapter da;

    conn.Open();

    par = new OracleParameter("@vPARAM1", OracleDbType.Varchar2, 50);

    par.Direction = ParameterDirection.Input;

    cmd.Parameters.Add(par);

    par = new OracleParameter("@vPARAM2", OracleDbType.Varchar2, 10);

    par.Direction = ParameterDirection.Output;

    cmd.Parameters.Add(par);

    cmd.Parameters["@vPARAM1"].Value = "ANTON";

    cmd.CommandType = CommandType.StoredProcedure;

    da = new OracleDataAdapter(cmd);

    cmd.ExecuteNonQuery();

    da.Fill(ds,"Table1");

    MessageBox.Show(ds.Tables.Count.ToString() + " - " +(cmd.Parameters["@vPARAM2"].Value).ToString());

    conn.Close();

    conn.Dispose();

     

    /*********************************************/

     

    TIA for all you help

     

    Tuesday, August 21, 2007 5:33 PM

All replies