String was not recognized as a Valid Date Time

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • pankajprakash
    New Member
    • Feb 2007
    • 70

    String was not recognized as a Valid Date Time

    Hi All,

    I Made a window application in c#.net and trying to fetch the record from the postgresql database. But whever i run the application "String was not recognized as a Valid Date Time" message show. This problem is arries from the database when it tries to fetch the record from a table in which timestampz datatype is used. so plz help me to solve this problem.
  • michaelb
    Recognized Expert Contributor
    • Nov 2006
    • 534

    #2
    It would help if you post the table definition and sql query that generates this error.

    Comment

    • pankajprakash
      New Member
      • Feb 2007
      • 70

      #3
      Originally posted by michaelb
      It would help if you post the table definition and sql query that generates this error.

      Actually there are so many functions and tables in which timstampz is used.

      i used following code


      IDataReader reader = Rget.ExecuteQue ry("Select * from f_record")

      then the error occure. In f_record function timestampz datatype is used.

      thanks for reply.

      Comment

      • michaelb
        Recognized Expert Contributor
        • Nov 2006
        • 534

        #4
        Can you please run select version() and post result here.
        Also, for further debugging it might be useful if you could connect to the database with psql, bypassing the API you're currently using.
        Is this option available to you?

        Comment

        • pankajprakash
          New Member
          • Feb 2007
          • 70

          #5
          Originally posted by michaelb
          Can you please run select version() and post result here.
          Also, for further debugging it might be useful if you could connect to the database with psql, bypassing the API you're currently using.
          Is this option available to you?

          Actually remoting is used in this application and when i run this application on remote system it truns fine but when i run in my local system this problem is coccurs.

          Comment

          • michaelb
            Recognized Expert Contributor
            • Nov 2006
            • 534

            #6
            There's one more thing I'll ask you to do.
            Check the Regional Settings on your computer. (Control Panel -> Regional and Language Options)

            If they are not set to "English (United States)" set them to it.
            (I don't remember if you have to reboot your PC after that)

            Then try your query again.

            Comment

            • pankajprakash
              New Member
              • Feb 2007
              • 70

              #7
              Originally posted by michaelb
              There's one more thing I'll ask you to do.
              Check the Regional Settings on your computer. (Control Panel -> Regional and Language Options)

              If they are not set to "English (United States)" set them to it.
              (I don't remember if you have to reboot your PC after that)

              Then try your query again.

              I have already set the region same for both the remote system and my local system. but problem still remain.

              Comment

              • michaelb
                Recognized Expert Contributor
                • Nov 2006
                • 534

                #8
                Can we try to summarize the differences between the successful execution and the failure you are having?
                Is the successful query originated from the same machine where the database is located?
                Is the API you are using (including s/w version if any) the same as on the other machine?
                You probably know better all other questions and answers along these lines.

                Also, did you ever try to run query select * from tablename
                just to take the function out of picture?

                Comment

                • pankajprakash
                  New Member
                  • Feb 2007
                  • 70

                  #9
                  Originally posted by michaelb
                  Can we try to summarize the differences between the successful execution and the failure you are having?
                  Is the successful query originated from the same machine where the database is located?
                  Is the API you are using (including s/w version if any) the same as on the other machine?
                  You probably know better all other questions and answers along these lines.

                  Also, did you ever try to run query select * from tablename
                  just to take the function out of picture?

                  Yes the query is running successfully in remote system and also my local system, but when i assing the result to datareader that time error occur.

                  Yes the API and the s/w version both are same on both system.

                  The problem still remain.

                  Comment

                  • pankajprakash
                    New Member
                    • Feb 2007
                    • 70

                    #10
                    Hi michaelb

                    Finally the poblem has been solved. The problem was in postgresql configuration. The solution is

                    click on start menu ->Postgresql 8.1->Configuratio n file ->Edit postgresql.conf

                    then a notepad document will be open
                    there is
                    datestyle =
                    timezone = # actually, defaults to TZ

                    so change the following

                    datestyle = 'US'
                    timezone = MST # actually, defaults to TZ

                    and then save the document

                    Thank you very much for you consontration. Really your help was great.

                    thank you

                    Comment

                    • michaelb
                      Recognized Expert Contributor
                      • Nov 2006
                      • 534

                      #11
                      Ah, so this means these two queries, successful, and failing, were ran against different servers.... something we never clarified.

                      Thank you for the feedback, this info on configuration may come very helpful for other people in the future.

                      Comment

                      Working...