As like the error message says it is not possible to convert the null or DbNull.Value to DateTime if you specify the expected datatype as SqlDbType.DateTime
in add method. So better option is AddWithValue. Use like the following:
command.Parameters.AddWithValue("@dateparameter", DBNull.Value);
For more link
Try Below Code
da.SelectCommand.Parameters.Add("@StartDate", SqlDbType.NVarChar).Value
= StartDate.ToString("dd-MMM-yyyy");
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.