如何解决编辑 SQL 表中的记录时出现 MS-Access 错误 - [Microsoft][ODBC Driver 17 for SQL Server] COUNT 字段不正确或语法错误
我最近尝试在运行 Windows Server 2019 的基于虚拟云的机器上运行正常运行的 MSAccess 数据库。编辑记录时,我的所有保存功能都无法在 PC 上运行。它们可以很好地在关联的 sql 表中创建新记录。下面是我的保存功能之一的示例。加载和创建新记录工作正常,只是编辑当前的 sql 记录会导致错误
[Microsoft][ODBC Driver 17 for sql Server] COUNT 字段不正确或语法错误
Private Function fSave() As Boolean 'True if Saved properly False on Error
Dim sqlConnectionString As String
Dim sqlConnectionUserName As String
Dim sqlConnectionPassword As String
sqlConnectionString = Forms!frm00SystemSettings!txtsqlConnectionString
sqlConnectionUserName = Forms!frm00SystemSettings!txtsqlConnectionUserName
sqlConnectionPassword = Forms!frm00SystemSettings!txtsqlConnectionPassword
Dim cnn As ADODB.Connection
Dim rst As ADODB.Recordset
Dim strsql As String
Set cnn = New ADODB.Connection
Set rst = New ADODB.Recordset
cnn.Open sqlConnectionString,sqlConnectionUserName,sqlConnectionPassword
If Isnothing(Me.txtIdentifier.Value) Then
strsql = "SELECT * " & _
"FROM vwM01commodity " & _
"WHERE commodityID = Null"
Else
strsql = "SELECT * " & _
"FROM vwM01commodity " & _
"WHERE commodityID = " & Me.txtIdentifier.Value
End If
rst.LockType = adLockOptimistic
rst.Open strsql,cnn
If rst.EOF Then
rst.AddNew
End If
rst.Fields("commodity") = Me.txtcommodity.Value
rst.Update
End Function
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。