Sometimes we will get the situation where we must insert NULL into datetime column in sql server.

Follow these steps to do that:

1) First Include the namespace:

using System.Data.SqlTypes;

2)  Declare

System.Data.SqlTypes.SqlDateTime getDate;
getDate = SqlDateTime.Null;

3) Insert using command Parameters

cmd11.Parameters.AddWithValue(“@encashed_date”, getDate);

——————————<>—————————————

Advertisement