dotnet tries to preformat odbc data datetime but fails

  • Thread starter Thread starter Roland Wolters
  • Start date Start date
R

Roland Wolters

Hi,


I am reading data from a unix odbc datasource in a c# program. Reading the
data as works fine, but one field, contains a date-time format that .net
does not understand.

The query would be: "Select birthdate from <tabel> where bla bla"

We use an odbc command object, and an odbcdatareader.

When I simple execute string result=(string)reader[0]; The .net code tries
to resolve it as a datetime. An error results.

When I try to read the data as bytearray (byte[]) I get the same error.

How can I prevent .net trying to render the data so I can parse it myself?


Greetings,

Roland

--
Roland Wolters
Work : http://www.wolters-ict.net
Private : http://www.habbiebabbie.net
Please reply to newsgroups only. Thanks.

"I have not failed. I've just found 10,000 ways that won't work."
- Thomas Alva Edison (1847-1931)
http://www.famousquotes.com/Show.php?_id=1000054
 
Change your query to return the datetime as a string , for example in
Oracle using TO_CHAR.
 
(e-mail address removed) wrote in @f14g2000cwb.googlegroups.com:
Change your query to return the datetime as a string , for example in
Oracle using TO_CHAR.

Yes, that would be a solution. How ever this is the problem: the database
belongs to a specialized morgage/crm application. The customer wants to
expose some data to the web. The database itself is inexcessible, but there
is a read-only odbc driver, but it's sql syntax is very poor. It was home-
build by de application builder. No luxory there!

Somehow I must be able to access the data in the reader as raw data.


Roland



--
Roland Wolters
Work : http://www.wolters-ict.nl
Private : http://www.habbiebabbie.net
Please reply to newsgroups only. Thanks.

"I have not failed. I've just found 10,000 ways that won't work."
- Thomas Alva Edison (1847-1931)
http://www.famousquotes.com/Show.php?_id=1000054
 
Did you try following?:
DateTime result = (DateTime)reader[0];

Or try: reader[0].GetType();
Then you at least know wich type you get.
 
Back
Top