title: datetime conversion failed when converting date or time from character string SQL (c#)
body: <p>I am trying to get my program to work, it is using parameters in an SQL query to add it to the database. When I run the program it comes up with &quot;datetime conversion failed when converting date or time from character string&quot;. I have tried many types of coding to make it work and all have failed. The SQL code itself works. It's simply the conversion that is breaking. I have tried multiple other posts on here and none have worked. Here's my code:</p>
  <pre class="lang-cs prettyprint-override"><code>string query = $&quot;UPDATE[***].[***]  SET [***]= '@FName', [***]= '@SName', [***] = '@Modified', [***] = '@Arrival', [***] = '@Departure'  where [Id] = '{id}'; &quot;;
  Dictionary&lt;string, string&gt; parameters = new Dictionary&lt;string, string&gt;();
  parameters.Add(&quot;@FName&quot;, record.guestGiven);
  parameters.Add(&quot;@SName&quot;, record.guestSurname);
  parameters.Add(&quot;@Modified&quot;, record.ModifiedDate.ToString());
  parameters.Add(&quot;@Arrival&quot;, Convert.ToString(record.arrivalDate));
  parameters.Add(&quot;@Departure&quot;, Convert.ToString(record.departureDate));
  mySuilvision.InsertData(query, parameters);
  </code></pre>
  <p>I also tried to do the following</p>
  <pre class="lang-cs prettyprint-override"><code>parameters.Add(&quot;@Modified&quot;, record.ModifiedDate.ToString(&quot;yyyy-mm-dd hh:MM:ss));
  </code></pre>
  <p>and all it came up with is the same error and for the last piece of code the VS error was &quot;cannot convert from string to system.IFormatProvider. Any help is appreciated.</p>