I have a stored procedure parameter as:
@ScmDate DateTime = NULL
From C# when I pass the parameter as below, it gives error: Error converting nvarchar to datetime.
if (txtWaitedDate.Text != "")
cmdTwMainEntry.Parameters.AddWithValue("@scmDate", Convert.ToDateTime(txtWaitedDate.Text));
Even though I have given default value of this parameter as NULL, but when the above C# condition is not fulfilled, it gives error.
Edited:
I get error only when I leave TextBox empty.
I suspect your date format is not what is expected by sql server, try to convert it with DateTime.TryParse and the right format provider for your SQL Server instance .
This error can happen for example when one is using mm/dd/yyyy format and the other is using dd/mm/yyyy.
EDIT
Changing the parameter type by hand should work anyway.
Try with this code, should work :