My problem deals w/inserting nulls into database (SQL Svr 2K) for the
datetime fields activityDate and followUpDate where nulls are allowed.
From the web form, the user can type in/select the activity or followup
date.
If, for this exercise, the followupdate textfield is empty, then when
the insert method of the class calls the InsertActivityL og stored
procedure, how can I get nulls inserted instead of 1/1/1900 because of
the use of DateTime.MinVal ue when instantiating the ActivityLog obj.
BTW, even though the activityDate and followUpDate have values of
{1/1/1} before running the stored proc, it will fail w/an overflow msg
that date has be to from 1795 to etc. Once the SqlDateTime.Nul l is cast
as a DateTime, the activityDate var now has the value of 1/1/1900. I'd
like to be able to have a null entry in the ActivityDate field. Then
again, I've been staring at this problem too long and probably can't
see the solution...
Thanks in advance for suggestions/comments,
Rey
*************** *************** *************** *
Below is the code snippet for the insert method.
if (activityDate == DateTime.MinVal ue)
activityDate = (DateTime)SqlDa teTime.Null;
cmd.Parameters. Add("@ActivityD ate", activityDate);
if (followUpDate == DateTime.MinVal ue)
followUpDate = (DateTime)SqlDa teTime.Null;
cmd.Parameters. Add("@FollowUpD ate", followUpDate);
Code snippet for getting values from various txtfields.
if (txtActivityDat e.Text != string.Empty)
actLog.activity Date = DateTime.Parse( txtActivityDate .Text.Trim());
else
if (txtActivityDat e.Text == string.Empty)
actLog.activity Date = DateTime.MinVal ue;