hdbc / hdbc-odbc

ODBC driver for HDBC
BSD 3-Clause "New" or "Revised" License
26 stars 34 forks source link

Connecting with HDBC-ODBC in Windows 7 #14

Open dkozhukhar opened 10 years ago

dkozhukhar commented 10 years ago

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 commented 10 years ago

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 commented 10 years ago

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 commented 10 years ago

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 commented 10 years ago

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 commented 5 years ago

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 (https://github.com/derrickturk/hdbc-odbc/commit/99cbefb16defc9ce6de77c1434207a78b5c3c365) has been submitted as a pull request.