How to fill my Typed DataSet with DataAdapter?

How to fill my Typed DataSet with DataAdapter?

Post by MJB » Fri, 18 Apr 2003 07:08:53



It's simple enough to fill a plain jane DataSet by executing a select
statement, but I have a typed dataset that I want filled.  Is there any way
to do this using the DataAdapter?

TIA,
Matt

 
 
 

How to fill my Typed DataSet with DataAdapter?

Post by Bill » Fri, 18 Apr 2003 08:08:33


Cross-posting makes us cross.
The DataAdapter is simply a Command manager. Setup the SelectCommand to
define your SELECT and use Fill.

--
____________________________________
Bill Vaughn
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________


Quote:> It's simple enough to fill a plain jane DataSet by executing a select
> statement, but I have a typed dataset that I want filled.  Is there any
way
> to do this using the DataAdapter?

> TIA,
> Matt


 
 
 

How to fill my Typed DataSet with DataAdapter?

Post by MJB » Fri, 18 Apr 2003 08:57:16


Bill,

    Thanks for the response.

    Respectfully, this is the correct way to "cross-post" so that when a
user responds in another news group the response is propagated throughout.
This subject is pertinent to all newsgroups posted to.  The incorrect way to
"cross-post" would have been to repeatedly post the message without CCing.

Regards,
--Matt



> Cross-posting makes us cross.
> The DataAdapter is simply a Command manager. Setup the SelectCommand to
> define your SELECT and use Fill.

> --
> ____________________________________
> Bill Vaughn
> www.betav.com
> Please reply only to the newsgroup so that others can benefit.
> This posting is provided "AS IS" with no warranties, and confers no
rights.
> __________________________________



> > It's simple enough to fill a plain jane DataSet by executing a select
> > statement, but I have a typed dataset that I want filled.  Is there any
> way
> > to do this using the DataAdapter?

> > TIA,
> > Matt

 
 
 

How to fill my Typed DataSet with DataAdapter?

Post by Vasile Marit » Fri, 18 Apr 2003 15:51:50


You can use OleDbDataAdapter or SqlDataAdapter and you have
many overloaded Fill methods.
You have also to configure the DataAdapter TableMapping before because
Fill method always consider a table named "Table" without mapping
You have to specify a mapping between "Table" and "TypedTableName"

SqlDataAdapter sqlData = new SqlDataAdapter();

sqlData.SelectCommand = new SqlCommand();

sqlData.SelectCommand.Connection = objSomeConnection;

sqlData.SelectCommand.CommandType = CommandType.Text;

sqlData.SelectCommand.CommandText = "SELECT * FROM tbXXXX";

sqlData.TableMappings.Add("Table", "TypedTableName");

TypedDataSet dataSet = new TypedDataSet();

sqlData.Fill(dataSet);

Note that TypedDataSet is your own defined DataSet containing a table named
"TypedTableName"

Regards,

Vasile


Quote:> It's simple enough to fill a plain jane DataSet by executing a select
> statement, but I have a typed dataset that I want filled.  Is there any
way
> to do this using the DataAdapter?

> TIA,
> Matt

 
 
 

How to fill my Typed DataSet with DataAdapter?

Post by Jame » Fri, 18 Apr 2003 17:09:56




> Cross-posting makes us cross.
> The DataAdapter is simply a Command manager. Setup the SelectCommand to
> define your SELECT and use Fill.

> --
> ____________________________________
> Bill Vaughn
> www.betav.com
> Please reply only to the newsgroup so that others can benefit.
> This posting is provided "AS IS" with no warranties, and confers no
rights.
> __________________________________



> > It's simple enough to fill a plain jane DataSet by executing a select
> > statement, but I have a typed dataset that I want filled.  Is there any
> way
> > to do this using the DataAdapter?

> > TIA,
> > Matt

That was actually a 'multi-post' and a good way to achieve posters aims.
 
 
 

How to fill my Typed DataSet with DataAdapter?

Post by MJB » Fri, 18 Apr 2003 22:23:04


Got it working.  Thank you!

--Matt


> You can use OleDbDataAdapter or SqlDataAdapter and you have
> many overloaded Fill methods.
> You have also to configure the DataAdapter TableMapping before because
> Fill method always consider a table named "Table" without mapping
> You have to specify a mapping between "Table" and "TypedTableName"

> SqlDataAdapter sqlData = new SqlDataAdapter();

> sqlData.SelectCommand = new SqlCommand();

> sqlData.SelectCommand.Connection = objSomeConnection;

> sqlData.SelectCommand.CommandType = CommandType.Text;

> sqlData.SelectCommand.CommandText = "SELECT * FROM tbXXXX";

> sqlData.TableMappings.Add("Table", "TypedTableName");

> TypedDataSet dataSet = new TypedDataSet();

> sqlData.Fill(dataSet);

> Note that TypedDataSet is your own defined DataSet containing a table
named
> "TypedTableName"

> Regards,

> Vasile



> > It's simple enough to fill a plain jane DataSet by executing a select
> > statement, but I have a typed dataset that I want filled.  Is there any
> way
> > to do this using the DataAdapter?

> > TIA,
> > Matt

 
 
 

1. Calling DataAdapter.Fill Multiple Times on Strongly Typed DataSet Causes Constraint Error

The MSDN documentation states:
You can use the Fill method multiple times on the same DataTable. If a
primary key exists, incoming rows are merged with matching rows that already
exist. If no primary key exists, incoming rows are appended to the
DataTable.

However; I am not finding this to be the case.  Whenever I call
.Fill(strongly_typed_dataset) multiple times against a DataTable with a
primary key defined I get the following error:

'Failed to enable contraints. One or more rows contain values violating
non-null, unique or foreign-key constraints'

Am I doing something wrong, is the documentation incorrect, or is this
problem a bug?

thanks,

wally

2. MINIX/ST's cc

3. DataAdapter.Fill() example for multiple fills.

4. WTB/RENT: Low-end Indy, 32/400, IRIX 5.2

5. DataAdapter.Fill() : will it add or replace the data in the dataset

6. Christmas Karaoke

7. Question about updating Master-Detail typed dataset thru DataAdapter.Update

8. SM symbol

9. A typed dataset can be filled from a web service ?

10. how to fill typed dataset from another DS

11. Filling a typed DataSet with one select?

12. Filling Multi Table Typed DataSet

13. Filling a Strongly Typed Dataset?