我正在研究将小型访问应用程序迁移到MariaDB的概念证明。
为了进行概念验证,我使用了mysql odbc开发人员指南中列出的代码:
https://dev.mysql.com/doc/connector-odbc/en/connector-odbc-examples-programming-vb-ado.html

所有示例代码都可以正常工作,直到下一节在“ rs.Update”处出现错误(无法更新记录)为止。为用户授予所有权限。

'rs insert rs.Open "select * from my_ado", conn, adOpenDynamic, adLockOptimistic rs.AddNew rs!Name = "Monty" rs!txt = "Insert row" rs.Update rs.Close

我在Win7 64位平台上使用MariaDB 10.1.19和MariaDB Connector / ODBC 2.0.16。

任何帮助,将不胜感激...

编辑:odbc跟踪的最后几行:

评估和B 1ad8-1f28 ENTER SQLColAttributesW
        HSTMT 0x004F1F30
        UWORD 3
        UWORD 16
        PTR 0x0D267D00
        剑258
        剑* 0x0018D2DC
        SQLLEN * 0x00000000

评估和B 1ad8-1f28退出SQLColAttributesW,返回码为-1(SQL_ERROR)
        HSTMT 0x004F1F30
        UWORD 3
        UWORD 16
        PTR 0x0D267D00
        剑258
        剑* 0x0018D2DC
        SQLLEN * 0x00000000

    DIAG [S1C00] [ma-1.0.6][10.1.19-MariaDB]Optional feature not implemented (0)


评估和B 1ad8-1f28 ENTER SQLGetDiagRecW
        SQLSMALLINT 3
        SQLHANDLE 0x004F1F30
        SQLSMALLINT 1
        SQLWCHAR * 0x0018D260
        SQLINTEGER * 0x0018CE38
        SQLWCHAR * 0x0018CE60
        SQLSMALLINT 512
        SQLSMALLINT * 0x0018CE48

评估和B 1ad8-1f28退出SQLGetDiagRecW,返回码0(SQL_SUCCESS)
        SQLSMALLINT 3
        SQLHANDLE 0x004F1F30
        SQLSMALLINT 1
        SQLWCHAR * 0x0018D260 [5]“ S1C00”
        SQLINTEGER * 0x0018CE38(0)
        SQLWCHAR * 0x0018CE60 [59]“ [ma-1.0.6] [10.1.19-MariaDB]未实现可选功能”
        SQLSMALLINT 512
        SQLSMALLINT * 0x0018CE48(59)

评估和B 1ad8-1f28 ENTER SQLGetDiagRecW
        SQLSMALLINT 3
        SQLHANDLE 0x004F1F30
        SQLSMALLINT 2
        SQLWCHAR * 0x0018D260
        SQLINTEGER * 0x0018CE38
        SQLWCHAR * 0x0018CE60
        SQLSMALLINT 512
        SQLSMALLINT * 0x0018CE48

评估和B 1ad8-1f28退出SQLGetDiagRecW,返回码100(SQL_NO_DATA_FOUND)
        SQLSMALLINT 3
        SQLHANDLE 0x004F1F30
        SQLSMALLINT 2
        SQLWCHAR * 0x0018D260
        SQLINTEGER * 0x0018CE38
        SQLWCHAR * 0x0018CE60
        SQLSMALLINT 512
        SQLSMALLINT * 0x0018CE48

评估和B 1ad8-1f28 ENTER SQLColAttributesW
        HSTMT 0x004F1F30
        UWORD 3
        UWORD 23
        PTR 0x0D267E10
        剑386
        剑* 0x0018D2DC
        SQLLEN * 0x00000000

评估和B 1ad8-1f28退出SQLColAttributesW,返回码0(SQL_SUCCESS)
        HSTMT 0x004F1F30
        UWORD 3
        UWORD 23
        PTR 0x0D267E10
        剑386
        剑* 0x0018D2DC(12)
        SQLLEN * 0x00000000

评估和B 1ad8-1f28 ENTER SQLColAttributesW
        HSTMT 0x004F1F30
        UWORD 3
        UWORD 22
        PTR 0x0D267FA0
        剑386
        剑* 0x0018D2DC
        SQLLEN * 0x00000000

评估和B 1ad8-1f28退出SQLColAttributesW,返回码0(SQL_SUCCESS)
        HSTMT 0x004F1F30
        UWORD 3
        UWORD 22
        PTR 0x0D267FA0
        剑386
        剑* 0x0018D2DC(6)
        SQLLEN * 0x00000000

评估和B 1ad8-1f28 ENTER SQLColAttributesW
        HSTMT 0x004F1F30
        UWORD 3
        UWORD 13
        PTR 0x00000000
        剑0
        剑* 0x00000000
        SQLLEN * 0x0018D2C8

评估和B 1ad8-1f28退出SQLColAttributesW,返回码为-1(SQL_ERROR)
        HSTMT 0x004F1F30
        UWORD 3
        UWORD 13
        PTR 0x00000000
        剑0
        剑* 0x00000000
        SQLLEN * 0x0018D2C8

    DIAG [S1C00] [ma-1.0.6][10.1.19-MariaDB]Optional feature not implemented (0)


评估和B 1ad8-1f28 ENTER SQLGetDiagRecW
        SQLSMALLINT 3
        SQLHANDLE 0x004F1F30
        SQLSMALLINT 1
        SQLWCHAR * 0x0018D244
        SQLINTEGER * 0x0018CE1C
        SQLWCHAR * 0x0018CE44
        SQLSMALLINT 512
        SQLSMALLINT * 0x0018CE2C

评估和B 1ad8-1f28退出SQLGetDiagRecW,返回码0(SQL_SUCCESS)
        SQLSMALLINT 3
        SQLHANDLE 0x004F1F30
        SQLSMALLINT 1
        SQLWCHAR * 0x0018D244 [5]“ S1C00”
        SQLINTEGER * 0x0018CE1C(0)
        SQLWCHAR * 0x0018CE44 [59]“ [ma-1.0.6] [10.1.19-MariaDB]未实现可选功能”
        SQLSMALLINT 512
        SQLSMALLINT * 0x0018CE2C(59)

评估和B 1ad8-1f28 ENTER SQLGetDiagRecW
        SQLSMALLINT 3
        SQLHANDLE 0x004F1F30
        SQLSMALLINT 2
        SQLWCHAR * 0x0018D244
        SQLINTEGER * 0x0018CE1C
        SQLWCHAR * 0x0018CE44
        SQLSMALLINT 512
        SQLSMALLINT * 0x0018CE2C

评估和B 1ad8-1f28退出SQLGetDiagRecW,返回码100(SQL_NO_DATA_FOUND)
        SQLSMALLINT 3
        SQLHANDLE 0x004F1F30
        SQLSMALLINT 2
        SQLWCHAR * 0x0018D244
        SQLINTEGER * 0x0018CE1C
        SQLWCHAR * 0x0018CE44
        SQLSMALLINT 512
        SQLSMALLINT * 0x0018CE2C

评估和B 1ad8-1f28 ENTER SQLFreeStmt
        HSTMT 0x004F1F30
        UWORD 2

评估和B 1ad8-1f28退出SQLFreeStmt,返回码0(SQL_SUCCESS)
        HSTMT 0x004F1F30
        UWORD 2

评估和B 1ad8-1f28 ENTER SQLFreeStmt
        HSTMT 0x004F1F30
        UWORD 0

评估和B 1ad8-1f28退出SQLFreeStmt,返回码0(SQL_SUCCESS)
        HSTMT 0x004F1F30
        UWORD 0

评估和B 1ad8-1f28 ENTER SQLFreeStmt
        HSTMT 0x004F3040
        UWORD 1

评估和B 1ad8-1f28退出SQLFreeStmt,返回码0(SQL_SUCCESS)
        HSTMT 0x004F3040
        UWORD 1

评估和B 1ad8-1f28 ENTER SQLFreeStmt
        HSTMT 0x004F1F30
        UWORD 0

评估和B 1ad8-1f28退出SQLFreeStmt,返回码0(SQL_SUCCESS)
        HSTMT 0x004F1F30
        UWORD 0

评估和B 1ad8-1f28 ENTER SQLFreeStmt
        HSTMT 0x004F1F30
        UWORD 1

评估和B 1ad8-1f28退出SQLFreeStmt,返回码0(SQL_SUCCESS)
        HSTMT 0x004F1F30
        UWORD 1

评估和B 1ad8-1f28 ENTER SQLDisconnect
        HDBC 0x004F1AC0

评估和B 1ad8-1f28 EXIT SQLDisconnect,返回码0(SQL_SUCCESS)
        HDBC 0x004F1AC0

评估和B 1ad8-1f28 ENTER SQLFreeConnect
        HDBC 0x004F1AC0

评估和B 1ad8-1f28退出SQLFreeConnect,返回码0(SQL_SUCCESS)
        HDBC 0x004F1AC0

评估和B 1ad8-1f28 ENTER SQLFreeEnv
        HENV 0x004F17B0

评估和B 1ad8-1f28退出SQLFreeEnv,返回码0(SQL_SUCCESS)
        HENV 0x004F17B0

评估和B 1ad8-1f28 ENTER SQLFreeEnv
        HENV 0x004F1828

评估和B 1ad8-1f28退出SQLFreeEnv,返回码0(SQL_SUCCESS)
        HENV 0x004F1828

最佳答案

我遇到了同样的问题。除了其他一些问题,此更新错误也使我发疯,因为尽管有此错误,但第一条记录已添加到maria-db中。当我从头开始测试时,我发现仅在upadte命令时也打开了其他记录集时才会发生此错误。
由于我不想重写访问代码,因此第一个快速而又肮脏的尝试是将更新命令包装在“下一步出错时恢复”中。事情解决了。

例如

Set rs = CurrentDb.OpenRecordset("...")
Set rs2 = CurrentDb.OpenRecordset(".....")
....
Do While Not rs.EOF
  rs2.AddNew
  rs2.Fields("...") = rs.Fields("...")
  rs2.Fields("...") = rs.Fields("...")
  ....
  ....
  On Error Resume Next
  rs2.Update
  On Error GoTo 0
Loop
....


希望这对您也有用。
请也不要担心日期和时间字段的潜在问题。

10-07 16:46