PC Review Forums Newsgroups Microsoft DotNet Microsoft ADO .NET How to Fill Typed DataSet

Reply

How to Fill Typed DataSet

 
Thread Tools Rate Thread
Old 07-02-2006, 06:10 PM   #1
Axel Dahmen
Guest
 
Posts: n/a
Default How to Fill Typed DataSet


Hi,

this might be a stupid question...

I've created a typed DataSet containing two tables and a
ForeignKeyConstraint. Now I want to Fill that DataSet from database using a
SELECT command retrieving rows for both tables.

However, when I use SqlDataAdapter.Fill() none or only the first table are
filled with data (depending on the Fill() overload I'm using).

Examining the Dataset I noticed that the Fill() method adds new tables to
the DataSet. How can I force Fill() to use the tables which are already
within the DataSet?

TIA,
Axel Dahmen

-----------------

This is the code I'm using:

adp=new SqlDataAdapter("SELECT * FROM Languages; SELECT * FROM
LanguagesCountries","user id=...;password=...;database=...");
_set=new TypedDataSet();
adp.Fill(_set,"Languages");


  Reply With Quote
Old 07-02-2006, 06:27 PM   #2
Sericinus hunter
Guest
 
Posts: n/a
Default Re: How to Fill Typed DataSet

You have to add table mapping before filling in order
to overwrite default table names:

adp.TableMappings.Add("Table", your_first_table_name);
adp.TableMappings.Add("Table1", your_second_table_name);
adp.TableMappings.Add("Table2", your_third_table_name);

and so on.

Axel Dahmen wrote:
> Hi,
>
> this might be a stupid question...
>
> I've created a typed DataSet containing two tables and a
> ForeignKeyConstraint. Now I want to Fill that DataSet from database using a
> SELECT command retrieving rows for both tables.
>
> However, when I use SqlDataAdapter.Fill() none or only the first table are
> filled with data (depending on the Fill() overload I'm using).
>
> Examining the Dataset I noticed that the Fill() method adds new tables to
> the DataSet. How can I force Fill() to use the tables which are already
> within the DataSet?
>
> TIA,
> Axel Dahmen
>
> -----------------
>
> This is the code I'm using:
>
> adp=new SqlDataAdapter("SELECT * FROM Languages; SELECT * FROM
> LanguagesCountries","user id=...;password=...;database=...");
> _set=new TypedDataSet();
> adp.Fill(_set,"Languages");
>
>

  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