This is an SQL Server tag, and not a XAML or .NET tag, so don't expect the best answers from that perspective.
But we SQL Server people frown upon .AddWithValue
, because it causes performance issues on the SQL Server side. Also the way, you use it, you will get a headache to date and time formats.
When you work with date and time, you very rarely use things like ToString("dd.MM.yyyy")
. Let the platform interpret and format the values according to the user's regional settings. And the format you use is not good at all. Is 02.12.2020 a date in December or in February? (Yes, there are people who interpret dates that way. I know it seems funny.)
The code should presumably be:
cmd.Parameters.Add("@date1", SqlDbType.Date).Value = SelectedDate_1.Value;
I say presumably, because being an SQL Server guy I don't know that much about date pickers. I know about writing data-access code, though.