PC Review Forums Newsgroups Microsoft DotNet Microsoft ADO .NET INSERT Statement with Empty Date

Reply

INSERT Statement with Empty Date

 
Thread Tools Rate Thread
Old 08-04-2006, 04:24 PM   #1
=?Utf-8?B?Z2xlbm4=?=
Guest
 
Posts: n/a
Default INSERT Statement with Empty Date


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.
  Reply With Quote
Old 09-04-2006, 05:44 PM   #2
Otis Mukinfus
Guest
 
Posts: n/a
Default Re: INSERT Statement with Empty Date

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
  Reply With Quote
Reply



Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off