Multiple resultsets to multiple DataGridView

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • code green
    Recognized Expert Top Contributor
    • Mar 2007
    • 1726

    #1

    Multiple resultsets to multiple DataGridView

    I am getting three resultsets from a stored procedure
    Code:
    //Create a DataAdapter, with the name of the stored procedure.
    SqlDataAdapter MyAdapter = new SqlDataAdapter("findOrders", myConnection);
    
    //Set the command type as StoredProcedure.
    MyAdapter.SelectCommand.CommandType = CommandType.StoredProcedure;
    DataSet DS = new DataSet();
    I pass a few parameters then try to bind each resultset to three different DataGridView via DataSet and BindingSource.
    I can get the first set into the first DataGridView showing Orders
    Code:
    MyAdapter.Fill(DS,"findOrders");
    dbBindSource.DataSource = DS.Tables["findOrders"];
    grdOrders.DataSource = dbBindSource;
    But when I write the second set to the second DataGridView showing Customers, this also overwrites the first DataGridView with the same data.
    Code:
    dbBindSource.DataSource = DS.Tables["BB_findOrders1"];
    grdCust.DataSource = dbBindSource;
    If I try with the third set of Order lines, this overwrites the first and second.
    Code:
    dbBindSource.DataSource = DS.Tables["BB_findOrders2"];
    grdPart.DataSource = dbBindSource
    Am I missing a command or doing it completely wrong?
  • code green
    Recognized Expert Top Contributor
    • Mar 2007
    • 1726

    #2
    Hmm, I'm guessing I need three BindingSource instances....

    Comment

    Working...