I think you need to place a breakpoint at the line:
DateTime expdate = Convert.ToDateTime(row.Cells[5].Value );
and look what
expdate
looks like by hovering over it with the mouse, the format is probably not correct for your stored procedure.
You should also check if row.Cells[5].Value is not NULL first.
It might also be needed to explicity specify the
SqlDbType
, like this:
command.Parameters.Add(new SqlParameter("@ExpDate", SqlDbType.DateTime2) { Scale = 3, Value = expdate });
More info here:
AddWithValue is Evil | Dan Guzman's Blog[
^]
See example here for
DateTimePicker
usage:
How to: Host Controls in Windows Forms DataGridView Cells | Microsoft Docs[
^]