468,507 Members | 1,577 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,507 developers. It's quick & easy.

typed datasets and default values

my setup:

visual studio 2005
sql server 2000

i'm using a dataset (used to be called typed dataset in 2003), where i
use the MSDataSetGenerator to create a class for me based on the scheme
of my SQL server. This schema doesn't include the default values that
are defined in the SQL server. It's setting all the default values to
NULL. is thre an easy way to get around this? for example, i have a
"quantity" (byte) column in the "orders" table with a default value of
5, i would want to see:

mydataset._orders.columns("quantity").quantity.def aultvalue == 5

right now that value is DBNULL.

Yes, i know i can go into the schema and change the default value
there, but if i change hte database and need to regenerate the data set
then i need to change all the default values again. Yes, i know i can
make a wrapper class around the dataset (i actually have one already)
and put in a function that sets all the default values to the ones i
want at creation, but i have lots of tables and lots of columns and
that would be quite tedious. It seems like there should be an easier
way.

Dec 8 '05 #1
1 2421
You could always extend the MSDataSetGenerator. You would have to call
to the base generator, and then parse the code with CodeDom. Then, you
would have to connect to SQL Server to get the default values for the
columns in your data set, and adjust those.

You shouldn't need a wrapper class around the dataset. Rather, have a
method that takes the data set and takes a connection (or uses one it
already has).

Then, what you do is select the default values from the database for the
columns in the tables in the dataset. Once you have these, you can cache
the values for your table, and then prevent the excessive database hits.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

<tg*******@gmail.com> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.com...
my setup:

visual studio 2005
sql server 2000

i'm using a dataset (used to be called typed dataset in 2003), where i
use the MSDataSetGenerator to create a class for me based on the scheme
of my SQL server. This schema doesn't include the default values that
are defined in the SQL server. It's setting all the default values to
NULL. is thre an easy way to get around this? for example, i have a
"quantity" (byte) column in the "orders" table with a default value of
5, i would want to see:

mydataset._orders.columns("quantity").quantity.def aultvalue == 5

right now that value is DBNULL.

Yes, i know i can go into the schema and change the default value
there, but if i change hte database and need to regenerate the data set
then i need to change all the default values again. Yes, i know i can
make a wrapper class around the dataset (i actually have one already)
and put in a function that sets all the default values to the ones i
want at creation, but i have lots of tables and lots of columns and
that would be quite tedious. It seems like there should be an easier
way.

Dec 8 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by pabloch2 | last post: by
4 posts views Thread by Ronald S. Cook | last post: by
5 posts views Thread by John | last post: by
21 posts views Thread by Peter Bradley | last post: by
1 post views Thread by Chris | last post: by
12 posts views Thread by BillE | last post: by
reply views Thread by NPC403 | last post: by
3 posts views Thread by gieforce | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.