有人可以帮助我吗?我不断收到此错误
错误:无法更新“注册”;字段不可更新。
Private Sub Test()
Dim conn As Object
Dim url As String
Dim table As String
Dim cmd As Object
Dim vehicle As ClsVehicle
On Error GoTo errHandler
Set conn = CreateObject("ADODB.Connection")
Set cmd = CreateObject("ADODB.Command")
url = "https://tenant.sharepoint.com/sites/Test/"
table = "934798bc-046e-4bb8-a608-913c86a5fdbd"
With conn
.connectionstring = "Provider=Microsoft.ACE.OLEDB.12.0;WSS;IMEX=2;RetrieveIds=Yes;" & _
"DATABASE=" & url & _
";LIST={" & table & "};"
.Open
End With
Set vehicle = New ClsVehicle
With vehicle
.setRegistration = "JS50LKGP"
.setPalletsCapacity = 0
.setTareWeight = 980
.setOwnerId = 1
End With
With cmd
.ActiveConnection = conn
.CommandText = "INSERT INTO [" & table & "] (registration, pallets_capacity, tare_weight, owner_id) " & _
"VALUES (?, ?, ?, ?)"
.CommandType = 1
.Parameters.Append .CreateParameter(, 200, 1, 255, vehicle.getRegistration)
.Parameters.Append .CreateParameter(, 3, 1, 0, vehicle.getPalletsCapacity)
.Parameters.Append .CreateParameter(, 5, 1, 0, vehicle.getTareWeight)
.Parameters.Append .CreateParameter(, 3, 1, 0, vehicle.getOwnerId)
.Execute
End With
errHandler:
Debug.Print "Error: " & Err.Description
End Sub
根据
https://www.connectionstrings.com/sharepoint/#:~:text=Use%20 Different%20SharePoint%20list%20connections%20for%20read%20(IMEX%3D2),您需要
IMEX=0
进行写入%20and%20写入%20(IMEX%3D0)%2C%20do%20not%20mix%20them