[英]HDBC-ODBC with MS Access 2016
I am unable to understand the error I am getting when I try to connect to a MS access database file 我无法理解尝试连接到MS Access数据库文件时遇到的错误
λ: :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: []"}
I got you, buddy, even if it's probably uselessly late! 我知道了,伙计,即使很晚也没用!
I just hit this exact issue and forked HDBC-odbc
to fix it. 我只是碰到了这个确切的问题,并分叉了HDBC-odbc
来修复它。 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
). 简而言之:他们“愚蠢地”信任SQLGetInfo
文档,该文档声称对于非字符串信息类型(例如,查询SQL_TXN_CAPABLE
时使用的SQLUSMALLINT
),或多或少会忽略BufferLength
参数。
Well, at least with the MS Access driver, that's not true. 好吧,至少对于MS Access驱动程序而言,这不是事实。 I tweaked the querying code to actually pass sizeof(SQLUSMALLINT)
instead of zero, and things seem to be working. 我调整了查询代码,以实际传递sizeof(SQLUSMALLINT)
而不是零,并且一切似乎都sizeof(SQLUSMALLINT)
。
The updated HDBC-odbc
can be had at https://github.com/derrickturk/hdbc-odbc . 可以在https://github.com/derrickturk/hdbc-odbc上获取更新的HDBC-odbc
。 I intend to put in a pull request as well, but I am not sure if HDBC-odbc
is still maintained. 我也打算提出一个拉取请求,但是我不确定是否仍然维护HDBC-odbc
。
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
): 无论如何,如果您使用stack
,那么就像更改stack.yaml
extra-deps
一样简单(替换以前的stack.yaml
HDBC-odbc
来源):
extra-deps: - git: https://github.com/derrickturk/hdbc-odbc.git commit: 99cbefb16defc9ce6de77c1434207a78b5c3c365
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.