Just so happened to check some old codes and found out how we assigned null values from code behind. The code looks like this:
System.Data.SqlTypes.SqlDateTime getDate;
getDate = SqlDateTime.Null;
if (DateDelivered.Text == "")
{
cmd.Parameters.Add(new SqlParameter("@DateDelivered ", SqlDbType.DateTime)).Value = getDate;
}
else
{
cmd.Parameters.Add(new SqlParameter("@DateDelivered ", SqlDbType.DateTime)).Value = DateTime.Parse(DateDelivered.Text);
}
I know it works fine. But I'm looking for ways for a better (or maybe shorter) approach.
No comments:
Post a Comment