How will the DataSet work with multiple Tables from database?

Hi!!!

Can the DataSet accommodate multiple tables from database Here's an example of what I mean:

Dim con As SqlClient.SqlDataAdapter = New SqlClient.DataAdapter

SQL statement: "SELECT * FROM TOInfo, TOInfo_OtherTOInfo, OtherTOInfo WHERE TOInfo.TONo = TOInfo_OtherTOInfo.TONo And TOInfo_OtherTOInfo.OtherTOInfoID = OtherTOInfo.OtherTOInfoID"

con.Fill (allTradingOrderDataSet, "TOInfo")

con.Fill (allTradingOrderDataSet1, "TOInfo_OtherTOInfo")

con.Fill (allTradingOrderDataSet2, "OtherTOInfo")

Public Property ReadOnly allTradingOrderlist As DataTables

Get

Return allTradingOrderDataSet.Tables("TOInfo")

Return allTradingOrderDataSet1.Tables("TOInfo_OtherTOInfo")

Return allTradingOrderDataSet2.Tables("OtherTOInfo")

End Get

End Property

Please do correct me if I'm wrong (I do have a feeling that I did it wrong). Hope you can help out. Thanks.



Answer this question

How will the DataSet work with multiple Tables from database?

  • Delphieur

    That won't work. It fills one joint table only.

    What you want to do is to create a command which returns multiple resultsets, something like:

    cmd.CommandText = ""select * from table1;select * from table2;.."



  • matt01

    If I understand your question correctly, you can add table(s) to a dataset.
    da.fill(ds, "tblTrades");
    da.fill(ds, "tblPensions");

    Then go through the dataset i.e. ds to pick the fields, etc of each table in the dataset...

    Hope this answers your question.


  • How will the DataSet work with multiple Tables from database?