【发布时间】:2021-03-15 21:09:37
【问题描述】:
我有一个 MySQL 数据库,我从中请求一个客户记录集,然后我根据两个字段过滤特定客户的记录集:1) 客户代码和 2) 适用年份。然后,我将用户表单对象中的值分配给 MySQL 字段,并将该特定客户端的记录更新到数据库中。
更新表时出现以下错误(运行“rstIT.Update”),我认为这与我实现过滤器的方式有关:
运行时错误“-2147467259 (80004005)”:[MySQL][ODBC 8.0(w) 驱动程序][mysqld-5.5.5-10.2.36-MariaDB-log-cll-lve]构建位置-> insert_fields() 失败
我确信必须有一种更简单/更聪明的方法来过滤正确的客户,并相应地更新记录。任何帮助解决我当前的问题或其他方法将不胜感激!
Dim cn As ADODB.Connection
Dim rstIT As ADODB.recordSet
Dim rstClients As ADODB.recordSet
Dim Jaar As String
Jaar = cboTaxPeriod.Text
ITID = lblClientCode.Caption
Application.DisplayAlerts = False
Dim str As String
str = "DRIVER={MySQL ODBC 8.0 Unicode Driver};SERVER=myserveraddress;DATABASE=mydatabasename;PORT=myport;UID=user_"
str = str & LCase(LoggedInName)
str = str & ";PWD="
str = str & Password
str = str & ";FOUND_ROWS=1;"
Set cn = New ADODB.Connection
cn.ConnectionString = str
cn.Open
Set rstIT = New ADODB.recordSet
With rstIT
.Open "IT", cn, adOpenKeyset, adLockOptimistic, adCmdTable
End With
rstIT.Filter = "ClientCode = '" & ITID & "' AND TaxYear = '" & Jaar & "'"
If rstIT.EOF Then
MsgBox "Client code does not exist in tax table.", vbOKOnly, "Choose new client code"
GoTo GaanUit 'This closes everything and exits
Else
rstIT!TaxStatus.value = LTrim(RTrim(cboTaxStatus.Text))
rstIT!TaxStatusStaff.value = RTrim(LTrim(lblTaxStatusStaff.Caption))
If lblDueDate.Caption <> "" Then
lblDueDate.Caption = Format(lblDueDate.Caption, "yyyy-mm-dd")
rstIT!DueDate.value = lblDueDate.Caption
Else
rstIT!DueDate = Empty
End If
End If
rstIT.Update
【问题讨论】:
-
你有一个 mariadb 并使用 mysql 8 驱动程序,你是否尝试了 mariadb 驱动程序?
-
nbk - 我将看看 MariaDB 驱动程序。据我所知,数据库是 MySQL。我对 MariaDB 不熟悉。
-
您的错误消息显示 5.5.5-10.2.36-MariaD 这仍然很旧,因为我们现在有 10.4 及更高版本