473,242 Members | 3,171 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,242 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 2802
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: WhiskyRomeo | last post by:
I have a bound textbox (bindings are set at design time) to a dataset column. Sometimes the value of this textbox must be set so that the underlying database field gets updated to null when using...
18
by: Dixie | last post by:
Can I set the Format property in a date/time field in code? Can I set the Input Mask in a date/time field in code? Can I set the Format of a Yes/No field to Checkbox in code? I am working on...
0
by: Darren Clark | last post by:
I am trying to set the default value (not mistaken for NULL value) for a datetime element of a typed dataset. <xs:element name="create_date" type="xs:dateTime"...
10
by: michael sorens | last post by:
Is it possible to store an unbound DataGridView component into a setting? I naively tried defining a Setting that is a DataGridView called DGV, then simply assigning it:...
2
by: Bob | last post by:
I have a CreatedOn field , datetime, which has GetDate() as the default value in SQL server 2000 table. When I create a new record in the table itself in enterprise manager, the field gets...
4
by: michael sorens | last post by:
I have successfully bound an XmlDocument to a DataGridView but all fields seem to be strings. I want to retrofit appropriate datatypes on some of the fields. Let me take this in 2 parts. Part...
1
by: laredotornado | last post by:
Hi, I'm using PHP 4.4.4 on Apache 2 on Fedora Core 5. PHP was installed using Apache's apxs and the php library was installed to /usr/local/php. However, when I set my "error_reporting"...
2
by: Brad Pears | last post by:
In my vb.net 2005 project I have a few combo boxes where I want to set a default value. I am not binding these combo boxes - I am loading the values directly in code from a dataset. Obviously...
8
by: Andrus | last post by:
..NET 2 Winforms application. How to create new setting and set it default value in userSettings section of app.config file or overwrite existing setting value ? I found code below in this list...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
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
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...

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.