Re: typed datasets and default values
- From: "Nicholas Paldino [.NET/C# MVP]" <mvp@xxxxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 8 Dec 2005 15:31:48 -0500
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]
- mvp@xxxxxxxxxxxxxxxxxxxxxxxxxxx
<tg.foobar@xxxxxxxxx> wrote in message
news:1134070608.001674.262350@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
> 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.defaultvalue == 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.
>
.
- References:
- typed datasets and default values
- From: tg . foobar
- typed datasets and default values
- Prev by Date: Re: Reflection and Assemblies
- Next by Date: Re: Delete a Row in Excel Spreadsheet
- Previous by thread: typed datasets and default values
- Next by thread: File.OpenRead and System.IO.IOException...
- Index(es):
Relevant Pages
|