Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Connecting with HDBC-ODBC in Windows 7 #14

Open
dkozhukhar opened this issue Jan 3, 2014 · 5 comments
Open

Connecting with HDBC-ODBC in Windows 7 #14

dkozhukhar opened this issue Jan 3, 2014 · 5 comments

Comments

@dkozhukhar
Copy link

When trying to connect to data source in Windows 7 with HDBC-ODBC rising SqlError {seState = "[]", seNativeError = -1, seErrorMsg = "sqlGetInfo SQL_TXN_CAPABLE: []"}

Using Haskell Platform 2013.2.0.0 and Microsoft Access Database Engine 2010 Redistributable are installed.

Sample code which i use:

import Database.HDBC 
import Database.HDBC.ODBC

main = do
  let connectionString =  "DBQ=D:\\PROGRAMS\\TEST\\TEST.MDB;Driver={Microsoft Access Driver (*.mdb, *.accdb)};"
  let ioconn = connectODBC connectionString
  conn <- ioconn
  vals <- quickQuery conn "SELECT TOP 10 * FROM testtab;" []
  print vals
@zenzike
Copy link
Member

zenzike commented Jan 6, 2014

I'm not familiar with the ODBC setup on Windows, but does the following return nicely, or does it produce an error?

:m + Database.HDBC Database.HDBC.ODBC
conn <- connectODBC "DBQ=D:\\PROGRAMS\\TEST\\TEST.MDB;Driver={Microsoft Access Driver (*.mdb, *.accdb)};"
hdbcDriverName conn

If it's an error, then I can only presume that your connection string isn't quite right.

@dkozhukhar
Copy link
Author

It gives same error after:

:m + Database.HDBC Database.HDBC.ODBC
conn <- connectODBC "DBQ=D:\\PROGRAMS\\TEST\\TEST.MDB;Driver={Microsoft Access Driver (*.mdb, *.accdb)};"

I also tried to give wrong DBQ and it returns Could not find file error. If I give the connection string to Excel it connects, but transfers it to DBQ=D:\\PROGRAMS\\TEST\\TEST.MDB;Driver={Microsoft Access Driver (*.mdb, *.accdb)};DriverId=25;FIL=MS Access;MaxBufferSize=2048;PageTimeout=5; If I use it as HDBC connection string it fails the same way as before.

@zenzike
Copy link
Member

zenzike commented Jan 9, 2014

Have you also tried following the instructions here:
http://www.haskell.org/haskellwiki/HDBC-ODBC_under_Windows
and installed the Microsoft Data Access Components (MDAC)
http://www.microsoft.com/en-us/download/details.aspx?id=5793

@dkozhukhar
Copy link
Author

I have tried to do that and system does not let me install MDAC 2.8 with error. It seems Windows 7 uses WDAC (Windows Data access Component) instead of MDAC and it comes preinstalled and can not be downgraded to MDAC 2.8.

@mpilgrem
Copy link

I had the same problem and error message on 64 bit Windows 10, with 64 bit Microsoft Access Version 1908 (Build 11929.20254 Click-to-Run) and the Microsoft Access Database Engine 2016 Redistributable fix, and a *.accdb file.

This Stack Overflow answer by @derrickturk and his fork of HDBC-odbc fixed it for me. I can't see that the fix he found (derrickturk@99cbefb) has been submitted as a pull request.

mpilgrem pushed a commit to mpilgrem/hdbc-odbc that referenced this issue Aug 31, 2019
@derrickturk has identified (derrickturk@99cbefb) that, in the case of the MS Access driver, the `BufferLength` argument of function `SQLGetInfo` cannot be ignored (set to 0), despite what is implied by the Microsoft documentation (https://docs.microsoft.com/en-us/sql/odbc/reference/syntax/sqlgetinfo-function?view=sql-server-2017).

`InfoType` `SQL_TXN_CAPABLE` returns a `SQLUSMALLINT` value and the `BufferLength` must be set accordingly.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants