Populating typed datasets WITHOUT tableadapters

C

Chris Smedley

Typed datasets are great, but in one respect, the move to use table adapters
is a double edge sword.

What I would like to be able to is to use the old fashion ds.tables()
components to be able to iterate through each of the tables in the typed
dataset and be able to fill them WITHOUT specifying each tableadapter .

Is there an easy way to do this that I am missing? if I use the Load Method,
I need to have a datareader and this means I need to get the selectcommand
for each table.
Are these accessible properties for each table?

I am sure I am missing something obvious


Thanks for your insight...
 
C

Cor Ligthert [MVP]

Chris,

Because of the fact that the typed dataset is so different between 1.x, 2.0
Windowforms and 2.0 Aspnet, can you tell us if you use this in WindowForms
or ASPNET? (The Load method makes it obvious that it is 2.0). However
telling it in advance next time will make it easier to help you.

Probably is than somebody more dedicated on that able to help you.

Cor
 
M

Miha Markic [MVP C#]

You are free to define a custom DataAdapter and use it to fill or update
typed dataset or any typed table.
Note that "typed" means just a layer on normal table.
 
C

Chris Smedley

To your question on win forms/asp/ etc... neither... it was a generalized
question on ADO.. the data layer. not the client layer.

I was drawn to use the type dataset because of the easy ability to drag and
drop objects from the SQL database... with all that entails, but it looks
like I am going to be encountering some of the issues with the N tier
discussions on the board.

What I want really to do is the following:

1) Be able to have a visual representation in VS ( like the typed dataset
XSD) that graphically represents the DB objects (Big surprise)

2) Have the ability to add new objects to this representation via drag and
drop methods (again check for typed datasets)

3) Have this representation automatically regenerate or modify itself
because on changes on the database (or at least easily). If I add a column
to the database, does it appear in the typed dataset automatically .This is
currently done by typed datasets...more or less.


The point is the key one:

4) Be able to AUTOMATICALLY populate a hierarchy of tables/entities based on
their relations.
It is quite easy to be able to determine the order of load based on
relationships between objects in many situations, and I would have thought
MSFT would have that ability by now :>
So for example if I drop a parent table into a typed dataset with an FK to
one of my other tables, you would think that it would automatically that
this NEW table needs:

a) a table adapters of the specifed type for the new table
b) that it needs to be loaded BEFORE the table already in the DB.

Instead that information is left to the programmer to do.

Because of this, instead, I was looking at writing a generic routine that
looks at all the tables and askews tableadapters. It will examine the
tables and their relations and load the data in the order needed in order to
avoid violating any dependent constraints.


Miha's comments on a custom data adapter may be the best path. too bad this
extremely common situation was not considered by MSFT in VS2005.
 
C

Cor Ligthert [MVP]

Chris,

But as long as you not tell in what VS there is no answer possible because
as I already wrote the creating of strongly typed dataset is done in
different ways depending on the version and type of use.

It is as telling that you want to do something with your car.

Cor
 
C

Chris Smedley

Ok... I must be missing something

I am building an IN MEMORY dataset... it will NOT be directly connected to a
windows form, an ASP page or any other FRONT END item. It will read from a
SQL database and right to a SQLdatabase.
Where I come from this is a data access layer component. so please tell me
(in detail) why the databinding (form/ASP,etc) are material?
 
C

Chris Smedley

as an addemndum to my eralier reply.. for the purpose of my application
consider this a Windows SERVICE
No client at all.. does that help "what kind of something i want to do with
my car"?
 
C

Cor Ligthert [MVP]

Chris,

Using other words, what are you using

Version 2002/2003 Net 1.x
Version 2005 Net 2.0 from which I understand now as it is Windowforms and
not ASPNET.

The designers from those build three different types of strongly typed
datasets.

Cor
 
C

Chris Smedley

Ok...lets walk down the road a little further... I am aware that they are
strongly typed datasets... thats my point.. the use of tableadapters would
have provided that information.
I think that your terms are nto clear.. you obviously know I am using a .Net
2.0 frame work... so it really DOES NOT matter if it is ASP or windows...
NOT AT ALL.


In any case my original message was related to OVERRIDING the use of the
strong typing by access properties within the table adapters to get the

SELECTCOMMAND and access the the dataadapters.

Again, I think miha comments on a custom adapter are the only way to go
considering that MSFT did not build the typed dataset as well as I would
have liked
 
M

Miha Markic [MVP C#]

Chris Smedley said:
Ok...lets walk down the road a little further... I am aware that they are
strongly typed datasets... thats my point.. the use of tableadapters would
have provided that information.
I think that your terms are nto clear.. you obviously know I am using a
.Net 2.0 frame work... so it really DOES NOT matter if it is ASP or
windows... NOT AT ALL.


In any case my original message was related to OVERRIDING the use of the
strong typing by access properties within the table adapters to get the

SELECTCOMMAND and access the the dataadapters.

Again, I think miha comments on a custom adapter are the only way to go
considering that MSFT did not build the typed dataset as well as I would
have liked

You mean the surrounding classes are not built well - yes, I agree - they
are just for sample projects IMO.
Your best bet is to avoid that stuff and use some sort of code generator or
a library that helps you building dataadapters and similar classes.
 
B

Benny S. Tordrup

I'm wondering if it is possible to disable the generation of the
TableAdapter class in the .NET 2.0 DataSet?

IMO is the DataSet class not the place to have the TableAdapter. I would use
the DataSet class as a data definition - possibly in it's own assembly to be
referenced by UI layer, DA layer etc. And the DA layer would be the correct
place for the TableAdapter classes.

Best regards,

Benny Tordrup

Miha Markic said:
You are free to define a custom DataAdapter and use it to fill or update
typed dataset or any typed table.
Note that "typed" means just a layer on normal table.

--
Miha Markic [MVP C#]
RightHand .NET consulting & development www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/

Chris Smedley said:
Typed datasets are great, but in one respect, the move to use table
adapters is a double edge sword.

What I would like to be able to is to use the old fashion ds.tables()
components to be able to iterate through each of the tables in the typed
dataset and be able to fill them WITHOUT specifying each tableadapter .

Is there an easy way to do this that I am missing? if I use the Load
Method, I need to have a datareader and this means I need to get the
selectcommand for each table.
Are these accessible properties for each table?

I am sure I am missing something obvious


Thanks for your insight...
 
B

Benny S. Tordrup

I'm wondering if it is possible to disable the generation of the
TableAdapter class in the .NET 2.0 DataSet?

IMO is the DataSet class not the place to have the TableAdapter. I would use
the DataSet class as a data definition - possibly in it's own assembly to be
referenced by UI layer, DA layer etc. And the DA layer would be the correct
place for the TableAdapter classes.

Best regards,

Benny Tordrup

Miha Markic said:
You are free to define a custom DataAdapter and use it to fill or update
typed dataset or any typed table.
Note that "typed" means just a layer on normal table.

--
Miha Markic [MVP C#]
RightHand .NET consulting & development www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/

Chris Smedley said:
Typed datasets are great, but in one respect, the move to use table
adapters is a double edge sword.

What I would like to be able to is to use the old fashion ds.tables()
components to be able to iterate through each of the tables in the typed
dataset and be able to fill them WITHOUT specifying each tableadapter .

Is there an easy way to do this that I am missing? if I use the Load
Method, I need to have a datareader and this means I need to get the
selectcommand for each table.
Are these accessible properties for each table?

I am sure I am missing something obvious


Thanks for your insight...



--
 
M

Miha Markic [MVP C#]

Hi Benny,

Benny S. Tordrup said:
I'm wondering if it is possible to disable the generation of the
TableAdapter class in the .NET 2.0 DataSet?

Not sure but you can delete TableAdapter after they are created (I know, i
know).
IMO is the DataSet class not the place to have the TableAdapter. I would
use the DataSet class as a data definition - possibly in it's own assembly
to be referenced by UI layer, DA layer etc. And the DA layer would be the
correct place for the TableAdapter classes.

So true, TableAdapters are like toys.

--
Miha Markic [MVP C#]
RightHand .NET consulting & development www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/
Best regards,

Benny Tordrup

Miha Markic said:
You are free to define a custom DataAdapter and use it to fill or update
typed dataset or any typed table.
Note that "typed" means just a layer on normal table.

--
Miha Markic [MVP C#]
RightHand .NET consulting & development www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/

Chris Smedley said:
Typed datasets are great, but in one respect, the move to use table
adapters is a double edge sword.

What I would like to be able to is to use the old fashion ds.tables()
components to be able to iterate through each of the tables in the
typed dataset and be able to fill them WITHOUT specifying each
tableadapter .

Is there an easy way to do this that I am missing? if I use the Load
Method, I need to have a datareader and this means I need to get the
selectcommand for each table.
Are these accessible properties for each table?

I am sure I am missing something obvious


Thanks for your insight...



--
----------------------------------------
Jeg beskyttes af den gratis SPAMfighter til privatbrugere.
Den har indtil videre sparet mig for at få 2000 spam-mails.
Betalende brugere får ikke denne besked i deres e-mails.
Hent gratis SPAMfighter her: www.spamfighter.dk
 
B

Benny S. Tordrup

Hi Miha,

Miha Markic said:
Not sure but you can delete TableAdapter after they are created (I know, i
know).

That's exactly what I do.

And what i further like with Visual Studio 2005 is the partial class making
it possible to enhance the dataset class without having enhancements deleted
by the designer :)

Best regards,

Benny Tordrup
 
B

Benny S. Tordrup

Hi Miha,

Miha Markic said:
Not sure but you can delete TableAdapter after they are created (I know, i
know).

That's exactly what I do.

And what i further like with Visual Studio 2005 is the partial class making
it possible to enhance the dataset class without having enhancements deleted
by the designer :)

Best regards,

Benny Tordrup




--
 
J

jmbledsoe

I don't want to sound like a marketing guy but your point #4
(Automatically populate a hierarchy of tables based on their relations)
is the exact same problem that I had. It was such a PITA, that I built
a tool to do this for me, and now my company is selling it (free to
try, and under $100 to buy). It's called the DataSet Toolkit, and it
has a class called the MultiTableDataAdapter which does exactly the
thing you want. Let me know what you think.

http://www.hydrussoftware.com

John B.
http://johnsbraindump.blogspot.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top