471,084 Members | 817 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

Setting the default value in a dataset

Hello
I have a datagrid with a datetimepicker column in it, which is bound to a dataset (MyDataset). The column in the dataset set that is mapped to the datetimepicker is called MyOrderDate and contains null values.

I have tried to following
to set the null values to 01/01/1900, as it doesn't accept nulls

The above command appears after filling the dataset with the schema like s
MySqlDataAdapter = New SqlDataAdapter(strquery, Mycon
MyDataSet = New DataSe
MySqlDataAdapter.FillSchema(MyDataSet, SchemaType.Source, strTable
Mydataset.Tables!MyTable.Columns(MyOrderDate).Defa ultValue = New DateTime(1900, 1, 1

MySqlDataAdapter.Fill(MyDataSet, strTable

When I check the values in the dataset for the rows that have have underlying null values the dataset has values o
system.dbNull despite the default setting above

Any ideas why this is happening

Mat

Nov 20 '05 #1
1 2517
Hi,

Default values only work for new records. You would have to loop
throught the data and change the nulls to 1/1/1900 manually. Here is a link
to a free datetimepicker that accepts null

http://www.codeproject.com/cs/miscct...Cpicker%7Cnull

Ken
-------------------------
"Matt Tinson" <an*******@discussions.microsoft.com> wrote in message
news:95**********************************@microsof t.com...
Hello,
I have a datagrid with a datetimepicker column in it, which is bound
to a dataset (MyDataset). The column in the dataset set that is mapped to
the datetimepicker is called MyOrderDate and contains null values.

I have tried to following
to set the null values to 01/01/1900, as it doesn't accept nulls.

The above command appears after filling the dataset with the schema like
so
MySqlDataAdapter = New SqlDataAdapter(strquery, Mycon)
MyDataSet = New DataSet
MySqlDataAdapter.FillSchema(MyDataSet, SchemaType.Source,
strTable)
Mydataset.Tables!MyTable.Columns(MyOrderDate).Defa ultValue =
New DateTime(1900, 1, 1)

MySqlDataAdapter.Fill(MyDataSet, strTable)

When I check the values in the dataset for the rows that have have
underlying null values the dataset has values of
system.dbNull despite the default setting above.

Any ideas why this is happening.

Matt

Nov 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Darren Clark | last post: by
10 posts views Thread by michael sorens | last post: by

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.