Instead of dynamically creating the SQL insert statement as strings, if you use either stored procedures or parameterized queries, you can pass the C # date and time value as a datetime object and there will be no format mismatch to cause problems.
[Correction - this only works on SQL 2008, see gbn answer for valid 2000/2005 string]
As an alternative, I believe that regardless of the regional settings of SQL servers, if you pass your time as a full ISO 8601 string, it will be processed correctly.
eg.
2010-03-10T14:17Z
Strike>
Personally, I would recommend parameterized queries or stored procedures, although they also solve many other problems.
source share