c# - Insert and select date from SQL Server database -


I get the following exception when trying to select data from SQL Server or inserting data with the C # window application is. I am passing on the date where the exception is shown below the section of the selection query in single quotes like '16 / 03/2011 ':

Out of a Datetime Time Data Type As a result of the range datetime price.

Is there any correct solution to enter and select dates from the relevant sqlserver database to the operating system. That is, both work on Italian and English OS.

If you can not use stored procs, or parameterized inquiries, you have a yyyy-mm-dd format You may want to format the date in East. '2011-03-16'

Include T-SQL sample

  Miteable values ​​('2011-03-16 ')   

or

  SELECT * to MyTable WHERE SomeDate & lt; = '2011-03-16'   

Also, keep in mind the part of the time of the day. If time is not important, then make sure you do not store it, because it can affect your SELECT query on the road.

Comments