LINQ update with NULL value.
-
Hi All, I am getting a problem when i try to update a datetime field with null value,I don't have any problem in while inserting a NULL value or updating with an another datetime value.I am getting this problem only while updating the datetime field with null values and i am using DBML. As i am new to linq concepts.I have used the following line of code. DateTime? Date = txtEnd.Text == string.Empty ? (DateTime?)null : Convert.ToDateTime(txtEnd.Text); Thanks, maxy.
-
Hi All, I am getting a problem when i try to update a datetime field with null value,I don't have any problem in while inserting a NULL value or updating with an another datetime value.I am getting this problem only while updating the datetime field with null values and i am using DBML. As i am new to linq concepts.I have used the following line of code. DateTime? Date = txtEnd.Text == string.Empty ? (DateTime?)null : Convert.ToDateTime(txtEnd.Text); Thanks, maxy.
The problem you are having isn't really a linq problem but deals with nullable types. When setting a nullable type to null you do not need to cast. Try this DateTime? Date = txtEnd.Text == string.Emtpy ? null : Convert.ToDateTime(txtEnd.Text);
-
The problem you are having isn't really a linq problem but deals with nullable types. When setting a nullable type to null you do not need to cast. Try this DateTime? Date = txtEnd.Text == string.Emtpy ? null : Convert.ToDateTime(txtEnd.Text);
Hey mac thanks for the reply man.I tried both ways yaar,if the problem was with my Nullable types then it should not even insert NULL Datetime values with the same function i used.Any ways thanks for the reply and even if you get any solution please post it. Thanks, maxy