积极答复者
我在VS2022中用Microsoft.ACE.OLEDB.12.0 访问 64位 Aeecss *.accdb文件时,能读和删除记录,但不能修改和增加记录

问题
答案
-
我闹了一个乌龙,是数据库的一个字段名我设置成User,这个是系统的限定语句词,在Access中没有问题,VS2022中能读数据,我就没引起注意,但对VS2022的更改数据程序就引发错误,我把User改成其它字段名,就一切正常了,谢谢你热心帮助!你说你的VS2022程序都正常,我才考虑是数据库方面的问题,堵了2,3天,终于解决问题了。
- 已标记为答案 jiaming zhao 2022年1月11日 23:50
- 已编辑 jiaming zhao 2022年1月11日 23:53
全部回复
-
Hi ,
能否提供你的完整代码(包括Update语句)?这样有助于我们分析你的问题并进行测试。
期待你的更新。
Best Regards,
Xingyu Zhao
Visual Basic and CLR forum will be migrating to a new home on Microsoft Q&A! (VB.NET and CLR) We invite you to post new questions in the new home on Microsoft Q&A ! For more information, please refer to the sticky post(VB.NET and CLR).
-
你好!我把代码整理如下,谢谢你的指教!
Public cnUA As New OleDbConnection
Public WithEvents daUA As OleDbDataAdapter
Public dsUA As DataSet
Public cmdC As OleDbCommandBuilder
cnUA.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & SPath & "NPD.accdb"
cnUA.Open()
Dim sqls As String
sqls = "SELECT * FROM UserManage ORDER BY User ASC"
daUA = Nothing
daUA = New OleDbDataAdapter(sqls, cnUA)
dsUA = Nothing
dsUA = New DataSet
daUA.FillSchema(dsUA, SchemaType.Source, "UserManage")
daUA.Fill(dsUA, "UserManage")
cmdC = Nothing
cmdC = New OleDbCommandBuilder(daUA)
daUA.UpdateCommand = cmdC.GetUpdateCommand
daUA.InsertCommand = cmdC.GetInsertCommand
daUA.DeleteCommand = cmdC.GetDeleteCommand
Dim dr As DataRow
For Each dr In dsUA.Tables(0).Rows
If dr("User") = "Admin" Then
dr("Password") = "0001"
daUA.Update(dsUA, "UserManage") '运行到这行出 Update 语法错误
Exit For
End If
Next
-
Hi ,
我使用Access2016和Access2010创建的accdb文件在vs2022中都进行了测试(按x64平台编译),发现都没有出现问题。
如果你使用Access2016或Access2010中的accdb文件测试会出现问题吗?
如果一切正常, 那么问题应和Office365相关,你可以考虑在以下论坛发帖:
https://techcommunity.microsoft.com/t5/developer/bd-p/Developer_Group
Best Regards,
Xingyu Zhao
Visual Basic and CLR forum will be migrating to a new home on Microsoft Q&A! (VB.NET and CLR) We invite you to post new questions in the new home on Microsoft Q&A ! For more information, please refer to the sticky post(VB.NET and CLR).
- 已编辑 Xingyu ZhaoMicrosoft contingent staff, Moderator 2022年1月6日 2:07
-
你好,我闹了一个乌龙,是数据库的一个字段名我设置成User,这个是系统的限定语句词,在Access中没有问题,VS2022中能读数据,我就没引起注意,但对VS2022的更改数据程序就引发错误,我把User改成其它字段名,就一切正常了,谢谢你热心帮助!你说你的VS2022程序都正常,我才考虑是数据库方面的问题,堵了2,3天,终于解决问题了。
- 已建议为答案 Xingyu ZhaoMicrosoft contingent staff, Moderator 2022年1月10日 2:11
-
Hi ,
很高兴你的问题得到解决,建议你将正确的回答标记为答案,这样帮助其他遇到类似问题的人快速找到解决方案。
Best Regards,
Xingyu Zhao
Visual Basic and CLR forum will be migrating to a new home on Microsoft Q&A! (VB.NET and CLR) We invite you to post new questions in the new home on Microsoft Q&A ! For more information, please refer to the sticky post(VB.NET and CLR).
-
我闹了一个乌龙,是数据库的一个字段名我设置成User,这个是系统的限定语句词,在Access中没有问题,VS2022中能读数据,我就没引起注意,但对VS2022的更改数据程序就引发错误,我把User改成其它字段名,就一切正常了,谢谢你热心帮助!你说你的VS2022程序都正常,我才考虑是数据库方面的问题,堵了2,3天,终于解决问题了。
- 已标记为答案 jiaming zhao 2022年1月11日 23:50
- 已编辑 jiaming zhao 2022年1月11日 23:53