Problem with reading time stamps via ODBC

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Problem with reading time stamps via ODBC

Jen Wu
Well, I decided to go ahead and try to use Dolphin to read a Paradox table
(it's just one table, so no joins required, and it's only reading from it).
It works great on text fields, but on timestamp fields, strange things
happen. Has anyone else run into this?  I fixed it, but it's kind of a
kludge, and if there's a better fix out there, I'd like to know about it.

Here's the code I used to read a record:

c := (DBConnection new) dsn: 'payment'; connect.
rs := c query: 'select ssn, paidthrudate from member'.
rs first.

When doing this, I get a bounds error. Turns out that the date field
(paidthrudate) has a length of 6, and the problem is occurring in the method
asTimeStamp in DBField:

minute := buffer wordAtOffset: 8.

I don't know if this problem applies to all Paradox tables, or just the one
I have, but I made a chance to the asTimeStamp method by adding some
exception handling:

 hour := [buffer wordAtOffset: 6] on: BoundsError do: [:err | 0].
 minute := [buffer wordAtOffset: 8] on: BoundsError do: [:err | 0].
 second := [buffer wordAtOffset: 10] on: BoundsError do: [:err | 0].
 fraction := [buffer dwordAtOffset: 12] on: BoundsError do: [:err | 0].

It's not very elegant, but it seems to work. Has anyone else run into this
and come up with a different way to handle it?

Thanks!

Jen