SQL
SqlDateTime myNullDate;
myNullDate = SqlDateTime.Null;
if (txtOrderCreated.Text == "")
{
cmd.Parameters.Add(new SqlParameter("@OrderCreated ", SqlDbType.DateTime)).Value = myNullDate;
}
else
{
cmd.Parameters.Add(new SqlParameter("@OrderCreated ", SqlDbType.DateTime)).Value = DateTime.Parse(txtOrderCreated.Text);
}
LINQ
var x = new tbl_Order();
if (txtOrderCreated.Text != "")
{
x.OrderCreated = DateTime.Parse(txtOrderCreated.Text);
}
else
{
x.OrderCreated = null;
}
No comments:
Post a Comment