ADO .addnew与ODBC for mariadb:错误

时间:2016-11-21 15:00:01

标签: mysql odbc mariadb ado

我正在研究将小型访问应用程序迁移到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 trace的最后几行:

估价和B 1ad8-1f28输入SQLColAttributesW         HSTMT 0x004F1F30         UWORD 3         UWORD 16         PTR 0x0D267D00         剑258         SWORD * 0x0018D2DC         SQLLEN * 0x00000000

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

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

估价和B 1ad8-1f28输入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输入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输入SQLColAttributesW         HSTMT 0x004F1F30         UWORD 3         UWORD 23         PTR 0x0D267E10         剑386         SWORD * 0x0018D2DC         SQLLEN * 0x00000000

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

估价和B 1ad8-1f28输入SQLColAttributesW         HSTMT 0x004F1F30         UWORD 3         UWORD 22         PTR 0x0D267FA0         剑386         SWORD * 0x0018D2DC         SQLLEN * 0x00000000

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

估价和B 1ad8-1f28输入SQLColAttributesW         HSTMT 0x004F1F30         UWORD 3         UWORD 13         PTR 0x00000000         SWORD 0         SWORD * 0x00000000         SQLLEN * 0x0018D2C8

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

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

估价和B 1ad8-1f28输入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输入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输入SQLFreeStmt         HSTMT 0x004F1F30         UWORD 2

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

1 个答案:

答案 0 :(得分:0)

我遇到了同样的问题。除了其他一些问题,此更新错误也使我发疯,因为尽管有此错误,但第一条记录已添加到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
....

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