Hello,
I’m sure I’m missing the obvious here but for some reason after I open a disconnected recordset from the database and then edit one of the records, when I go to update the database with out changing the Primary Key data I get the following error
“Violation of PRIMARY KEY constraint 'PK_Test'. Cannot insert duplicate key in object 'Test'. “Err.Number –2147217900”
Any help would be greatly appreciatedCode:Public Sub OpenDb() With rs .ActiveConnection = "Provider=SQLOLEDB;" & _ "Data Source=SQL_001;" & _ "Database=Test;" & _ "UID=sa;" & _ "PWD=;" .CacheSize = 1 .CursorLocation = adUseClient .CursorType = adOpenKeyset .LockType = adLockBatchOptimistic .Source = "Manufacture" .Open End With rs.ActiveConnection = Nothing End Sub Public Sub UpDateDb() If bIsDirty = True Then rs.ActiveConnection = "Provider=SQLOLEDB;" & _ "Data Source= SQL_001;" & _ "Database=Test;" & _ "UID=sa;" & _ "PWD=;" rs.UpdateBatch rs.ActiveConnection = Nothing End If End Sub




Reply With Quote