Recent

Author Topic: [Solved] Linux mdbtools-odbc longint data  (Read 2220 times)

iru

  • Full Member
  • ***
  • Posts: 224
[Solved] Linux mdbtools-odbc longint data
« on: April 28, 2016, 01:29:21 pm »
Gentlefolk,

Environment: Linux Mint 17.3, Laz 1.6, fpWeb installed.
Underlying ODBC is "mdbtools" (the only ODBC mechanism system that I could install and run without obscure installation problems, a driver that worked, etc (I may be the problem here!)).

I have a program which successfully access an Access/jet/.mdb database.
It will read a table and display "character" columns correctly.

"LongInt" integers do not display correctly!

The statement  " SQLBindCol(stmtHandle,1,SQL_INTEGER,SQLPointer(@ResID),4,@ErrCode);" defines column1 in the table.

The statement "Res:=SQLFetch(StmtHandle);" makes each entry in the table accessible.
The contents of column 1 should be accessible in "ResID" Which is a "LongInt".

I can inspect the contents of the .mdb file with the MDBTOOLS file viewer and display the table and correct values for column 1 (for example a row entry with column 1 = 752) .

Using the Bless hex editor I can inspect the contents of the .mdb file and locate the appropriate row and  column 1. In hex it is F2:02:00:00 which is 752 in "little endian" format.

Run the program and I get ResID = 842348288, SwapEndian(ResID) = ResDebug = 3618098 (may actually be from a row with col 1 = 751 or 753 (having problems with the row count.....))

Any help appreciated, Ian.


« Last Edit: April 29, 2016, 07:41:07 am by iru »

marcov

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 7431
Re: Linux mdbtools-odbc longint data
« Reply #1 on: April 28, 2016, 01:44:56 pm »
ResID = 842348288,

This is hex $32353700  which is an ascii string #0'752'

So it seems a string is interpreted as integer somewhere.

iru

  • Full Member
  • ***
  • Posts: 224
[Solved]Re: Linux mdbtools-odbc longint data
« Reply #2 on: April 29, 2016, 07:40:21 am »
Marcov,

Well done!!!! I did not see that at all.

There is something funny down in the odbc-access API. Everything I can see indicates that the returned data should be a LongInt.

Thanks, Ian.

mig-31

  • Sr. Member
  • ****
  • Posts: 259
Re: [Solved] Linux mdbtools-odbc longint data
« Reply #3 on: April 29, 2016, 10:10:00 am »
Why are you using mdb (Access file) database under Linux?
It is better to use SQL Lite or Firebird or other. You can a access to SQL Lite/Firebird through ODBC driver or directly.


Lazarus 2.0.2 - CentOS 7.x, Mageia 7.1