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;


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

    par.Direction = ParameterDirection.Input;


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

    par.Direction = ParameterDirection.Output;


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

    cmd.CommandType = CommandType.StoredProcedure;

    da = new OracleDataAdapter(cmd);



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






    TIA for all you help


    Tuesday, August 21, 2007 5:33 PM

All replies

  • Hi, maybe you could check this link to see if it solve your problem.



    Tuesday, August 21, 2007 6:27 PM
  • Are you sure that "Table1" is the correct name for the table that contains your result data?

    Tuesday, August 21, 2007 7:56 PM
  • I'm just naming that table in the dataset 'Table1'.  I also tried 'da.Fill(ds)' and referenced the table as ds.Tables[0].cou.....


    I also tried just filling a DataTable.....to no avail.  It was also empty.  However, like I mentioned previously, I could get all the values one by one, or through a DataReader I suppose...or even by creating a datatable by looping through all the parameters.


    ...but shouldn't I be able to just put the results in a datatable or dataset?

    Tuesday, August 21, 2007 8:52 PM