- Joined
- Feb 2, 2009
- Messages
- 2
- Reaction score
- 0
The code will insert DateTime as 01 Jan 1910, how can it be inserted as blank ?
Code:
DateTime Date2;
[B]WebForm[/B]
if (txtDate.Text.ToString() == "")
{
Date2 = Convert.ToDateTime("1910/Jan/01");
}
else
{
Date2 = Convert.ToDateTime(txtDate.Text.ToString());
}
[B]DB[/B]
if (demItem.InvoiceDate.ToString("yyyy/MM/dd") == "1910/Jan/01")
{
cm.Parameters["@invoiceDate"].Value = DBNull.Value;
}
else
{
cm.Parameters["@invoiceDate"].Value = Convert.ToDateTime(Date2);
}