0

I am unable to understand the error I am getting when I try to connect to a MS access database file

λ: :m + Database.HDBC Database.HDBC.ODBC
λ: let connectionString = "DBQ=c:\\Users\\user\\Desktop\\Database1.accdb;Driver={Microsoft Access Driver (*.mdb, *.accdb)};"
λ: conn <- connectODBC connectionString

*** Exception: SqlError {seState = "[]", seNativeError = -1, seErrorMsg = "sqlGetInfo SQL_TXN_CAPABLE: []"}
duplode
  • 33,731
  • 7
  • 79
  • 150
matt
  • 1,817
  • 14
  • 35
  • [1/2] [This seems to be the same problem](https://github.com/hdbc/hdbc-odbc/issues/14), but there is no clear solution offered at the GitHub issue. More optmistically, perhaps you just need to install the appropriate ODBC drivers (cf. this [discussion at a Microsoft forum](https://answers.microsoft.com/en-us/msoffice/forum/msoffice_excel-mso_other/no-odbc-drivers-available-for-excel-or-access-in/001c234b-dfd5-4378-a325-c4f1482fb6fd), and what I think is [the relevant download](https://www.microsoft.com/en-us/download/details.aspx?id=13255)). – duplode Feb 24 '17 at 15:16
  • [2/2] (I remember that, a long time ago, I had to install some ODBC driver so that HDBC could talk with SQL Server on Windows 7. Unfortunately, I can't recall the excat details of what I did back then, nor am I able to attempt reproducing your problem at the moment.) – duplode Feb 24 '17 at 15:19

1 Answers1

1

I got you, buddy, even if it's probably uselessly late!

I just hit this exact issue and forked HDBC-odbc to fix it. In short: they "foolishly" trusted the MSDN documentation for SQLGetInfo, which claims that the BufferLength parameter is more-or-less ignored for non-string information types (say, the SQLUSMALLINT used when querying SQL_TXN_CAPABLE).

Well, at least with the MS Access driver, that's not true. I tweaked the querying code to actually pass sizeof(SQLUSMALLINT) instead of zero, and things seem to be working.

The updated HDBC-odbc can be had at https://github.com/derrickturk/hdbc-odbc. I intend to put in a pull request as well, but I am not sure if HDBC-odbc is still maintained.

In any case, if you use stack, it's as easy as changing your extra-deps in stack.yaml to include (replacing any previous source of HDBC-odbc):

extra-deps:
  - git: https://github.com/derrickturk/hdbc-odbc.git
    commit: 99cbefb16defc9ce6de77c1434207a78b5c3c365
Derrick Turk
  • 4,246
  • 1
  • 27
  • 27