PC Review Forums Newsgroups Microsoft DotNet Microsoft ADO .NET populating two separate tables from 1 dataset

Reply

populating two separate tables from 1 dataset

 
Thread Tools Rate Thread
Old 16-03-2004, 01:36 AM   #1
Mike Cooper
Guest
 
Posts: n/a
Default populating two separate tables from 1 dataset


This is probably an easy question, but I can't find the answer
anywhere. I have two datatables in my Main_Dataset (untyped). One
table contains all of the information from the table in my database.
The other is supposed to contain only 5 columns of information.

The first table, the comprehensive one, fills fine and populates a
datagrid. The second one does not populate at all. I am attempting
to fill it will a second (dataadapter).fill command, using a small
datamap than in the first. So I have two tablemappings, each
configured the same except one only contains 5 columns.

This does not work, though it also doesn't error, so I have no idea
what is going on. Is this a valid way to fill a second table in a
dataset? If not, then how DO you populate multiple tables in a
dataset? Do you need a second data adapter? This seems wasteful;
making two calls to the database to retrieve the same information.


Thanks,
Mike Cooper
  Reply With Quote
Old 16-03-2004, 03:56 PM   #2
Brian Parlier
Guest
 
Posts: n/a
Default Re: populating two separate tables from 1 dataset

If the data is coming from the same database then you can use the same
dataadapter to fill a dataset, however, if you want to update the data in
both datatables and submit those changes then you should use two
dataadapters.

Filling two datatables:

Dim ds As New DataSet()
Dim dap As New xxxDataAdapter("SELECT SomeData From SomeTable",
connectionObj)

dap.Fill(ds, "FirstTable")

dap.SelectCommand.CommandText = "Select SomeData From SomeOtherTable"

dap.Fill(ds, "SecondTable")

Hope this helps
Brian Parlier


"Mike Cooper" <bidalah@yahoo.com> wrote in message
news:df4443e2.0403151636.18a2facb@posting.google.com...
> This is probably an easy question, but I can't find the answer
> anywhere. I have two datatables in my Main_Dataset (untyped). One
> table contains all of the information from the table in my database.
> The other is supposed to contain only 5 columns of information.
>
> The first table, the comprehensive one, fills fine and populates a
> datagrid. The second one does not populate at all. I am attempting
> to fill it will a second (dataadapter).fill command, using a small
> datamap than in the first. So I have two tablemappings, each
> configured the same except one only contains 5 columns.
>
> This does not work, though it also doesn't error, so I have no idea
> what is going on. Is this a valid way to fill a second table in a
> dataset? If not, then how DO you populate multiple tables in a
> dataset? Do you need a second data adapter? This seems wasteful;
> making two calls to the database to retrieve the same information.
>
>
> Thanks,
> Mike Cooper



  Reply With Quote
Reply



Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off