473,327 Members | 1,892 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

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 2686
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: DraguVaso | last post by:
Hi, Something I don't understand about a Typed DataSet: When a value in the DataSet is DBNull, it throws this error: "Cannot get value because it is DBNull". But aren't Typed DataSets...
2
by: pabloch2 | last post by:
Why the data access layer should use untyped datasets? and Why the business layer should use strongly typed datasets? Is this applicable to the 3 layered architecture in general or is it related...
4
by: Ronald S. Cook | last post by:
I've always used untyped datasets. In a Microsoft course, it walks through creating typed datasets and harps on the benefits. It has you drag all these things around ..wizard, wizard, wizard......
5
by: John | last post by:
Hi, I am developing a windows app using C# 2005. This app uses SQL Server or Oracle database depending on the what the user is using. Can I create one typed dataset and use it for SQL Server and...
21
by: Peter Bradley | last post by:
Hi all, This post is sort of tangentially related to my earlier posts on configuration files for DLLs. Does anyone know how to create typed DataSets using VS2005's new DataSet designer, but...
1
by: Chris | last post by:
Are there any performance issues with typed datasets in a fairly high performance system?
12
by: BillE | last post by:
I'm trying to decide if it is better to use typed datasets or business objects, so I would appreciate any thoughts from someone with more experience. When I use a business object to populate a...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.