C#.NET: String was not recognized as a valid DateTime

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dhanashivam
    New Member
    • Mar 2007
    • 31

    C#.NET: String was not recognized as a valid DateTime

    hi,

    in my web application i am getting date values from sql server database and store in the datatable.

    it works fine when i use the US culture. But when i change the culture to british i am getting the error.

    String was not recognized as a valid DateTime.Couldn 't store <22/02/08> in dt1 Column. Expected type is DateTime.

    Any one please can help me?

    i directly fill the data to the datatable by a select statement.

    Thanks in Advance.

    Regards,
    Dhanasekaran. G
  • radcaesar
    Recognized Expert Contributor
    • Sep 2006
    • 759

    #2
    Are you using the DatTime datatype to store the dates ?

    Comment

    • radcaesar
      Recognized Expert Contributor
      • Sep 2006
      • 759

      #3
      Its seems that your problem is with the datatype in the datatable. Check that..

      Comment

      • Plater
        Recognized Expert Expert
        • Apr 2007
        • 7872

        #4
        It looks like you are trying to use a string representation to insert the value into the database. Use the DateTime object itself on inserting. (SqlParameters work well for this behaviour)

        Comment

        • todashah
          New Member
          • Feb 2008
          • 26

          #5
          Hi !

          In such case you have go in control panel & select Regional & Languange
          Option & in that set the standard & foramat as a English(United Kingdom).
          I hope its work perfectly.

          Bye....Take Care,

          Dhaval Shah
          Originally posted by dhanashivam
          hi,

          in my web application i am getting date values from sql server database and store in the datatable.

          it works fine when i use the US culture. But when i change the culture to british i am getting the error.

          String was not recognized as a valid DateTime.Couldn 't store <22/02/08> in dt1 Column. Expected type is DateTime.

          Any one please can help me?

          i directly fill the data to the datatable by a select statement.

          Thanks in Advance.

          Regards,
          Dhanasekaran. G

          Comment

          Working...