By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,654 Members | 1,840 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,654 IT Pros & Developers. It's quick & easy.

String was not recognized as a Valid Date Time

P: 70
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.
Feb 8 '07 #1
Share this Question
Share on Google+
10 Replies


Expert 100+
P: 534
It would help if you post the table definition and sql query that generates this error.
Feb 8 '07 #2

P: 70
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.ExecuteQuery("Select * from f_record")

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

thanks for reply.
Feb 8 '07 #3

Expert 100+
P: 534
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?
Feb 8 '07 #4

P: 70
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.
Feb 8 '07 #5

Expert 100+
P: 534
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.
Feb 8 '07 #6

P: 70
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.
Feb 8 '07 #7

Expert 100+
P: 534
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?
Feb 8 '07 #8

P: 70
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.
Feb 9 '07 #9

P: 70
Hi michaelb

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

click on start menu ->Postgresql 8.1->Configuration 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
Feb 9 '07 #10

Expert 100+
P: 534
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.
Feb 9 '07 #11

Post your reply

Sign in to post your reply or Sign up for a free account.