PC Review
Forums
Newsgroups
Microsoft DotNet
Microsoft ADO .NET
INSERT Statement with Empty Date
Forums
Newsgroups
Microsoft DotNet
Microsoft ADO .NET
INSERT Statement with Empty Date
![]() |
INSERT Statement with Empty Date |
|
|
Thread Tools | Rate Thread |
|
|
#1 |
|
Guest
Posts: n/a
|
Hi folks,
I am using an Access database, VB.NET and ADO.NET working with a DataGrid control. MY datagrid table has both a date_sent and a date_ans field. When I Insert a record in my SQL statement, I insert a date_sent but I need to insert a blank date_ans field. date_sent is the date when a question was sent to a group from a web form and date_ans is the date when a question was answered. I need to have the datagrid initially show the date_ans field with a date shown and with the date_sent field having nothing shown. The date_ans field is later filled in with an UPDATE statement. I can put in a date into the date_ans field from my INSERT statement but it is confusing to the user and will be bogus information but a valid date is the only thing my query function, which passes the date_ans as a parameter, as being acceptable. I need to somehow find a way to have the app recognize a date as being a valid date which shows up as an empty value in the date_ans field. Thanks for any insight on this. |
|
|
|
#2 |
|
Guest
Posts: n/a
|
On Sat, 8 Apr 2006 08:24:02 -0700, glenn <glenn@discussions.microsoft.com>
wrote: >Hi folks, > >I am using an Access database, VB.NET and ADO.NET working with a DataGrid >control. > >MY datagrid table has both a date_sent and a date_ans field. When I Insert >a record in my SQL statement, I insert a date_sent but I need to insert a >blank date_ans field. date_sent is the date when a question was sent to a >group from a web form and date_ans is the date when a question was answered. > >I need to have the datagrid initially show the date_ans field with a date >shown and with the date_sent field having nothing shown. The date_ans field >is later filled in with an UPDATE statement. > >I can put in a date into the date_ans field from my INSERT statement but it >is confusing to the user and will be bogus information but a valid date is >the only thing my query function, which passes the date_ans as a parameter, >as being acceptable. > >I need to somehow find a way to have the app recognize a date as being a >valid date which shows up as an empty value in the date_ans field. > >Thanks for any insight on this. You will have to set the date in the table to DBNull.Value when you insert it. However, when you display it you will have problems when reading it back from the database, because a DateTime object cannot be null in .NET 1.1. In .NET 2.0 you can set the DateTime object to a "nullable type". If you are using .NET 2.0 search for "nullable type" in the IDE help (Thank you MS for finally doing something about this issue). Good luck with your project, Otis Mukinfus http://www.arltex.com http://www.tomchilders.com |
|
![]() |
|
| Thread Tools | |
| Rate This Thread | |
|
|

Main Page 

