Multiple Data Sets

dobbo

Member
Joined
May 14, 2003
Messages
5
Location
Melbourne
I have a VB.NET windows app which calls a single stored proc which returns a dataset containing multiple tables.

At the moment the only way I can seem to refernence the various tables is through the standard code: -

DataSet.Tables("Table"), DataSet.Tables("Table1"), DataSet.Tables("Table2") .... and so on.

Is there any way that I can assign specific names to the individual tables when the dataset is created?????
 
Why dont you generate a Dataset File. Dataset1.xsd
after generating that you just need to add an instance of it with in your application. and you can fill its tables.
 
try this:

Code:
 m_odaWhatever.Fill(m_dsWhatever, "TableNameWhatever")
 
Thanks for the replies ..... but Im still missing something.

Creating a DataSet schema file will allow me to declare 2 tables within the dataset eg. Author & Title ..... fine.

However if I call my stored procedure (which will return one record set for Authors and another for Titles) with the command

m_odaWhatever.Fill(m_dsWhatever, "Authors")

the tables in the DataSet are doing to be called Authors & Authors1 - I want them to be called Authors & Title.

How do I use the .xsd to acheive this??

Cheers!!!!
 
If via visual studio: right click the dataset in question and select properties. In the Properties window, select the Tables property, and then click the ellipsis button. The Tables Collection Editor opens. Select the table and change both the Name and TableName properties to the name you want to use.

If via run time: the following code creates the Authors table:

Code:
Dim dtAuthors As System.Data.DataTable
dtAuthors = Me.dsDataSet.Tables.Add("Authors")
[code=vb]

Then you fill the dataset thus:
[code=vb]
Me.daDataAdapter.Fill(Me.dsDataSet.Tables("Authors"))

Jon
 
Back
Top