I scussefully connect an ADODB.Recordset with a PostgreSQL Table:
Set rs.ActiveConnection = con
rs.Source = psql
rs.LockType = adLockPessimistic
rs.CursorType = adOpenKeyset
rs.index = "id"
rs.Open
I can update data:
rs!somefield = "somevalue"
rs.update
I can add data:
rs.AddNew
rs!someRequiredFiled = "somevalue"
rs.update
But updating data is not working, if the data is changed in background:
rs!somefield = "somevalue"
// .... the same field was changed for an other user
rs.update
// -> Error, cause the field to be changed is not found anymore
I think the Problem is, that the Recordset is not informed about the primary key. Right? And how can I set the Primary key?
When using a client-side cursor, the record generally is identified by its primary key, or, if that's not present, the record isn't updateable.
When using a server-side cursor, the server keeps track of which record you're working on, and it can be identified by things like a primary key or a rowversion indicator. If the server is tracking a specific row version, and that row gets changed, it will lose track of it if it's not notified.
Use Connection.CursorLocation = adUseClient
to use a client-side cursor.
The Recordset.Index
property is used for something else entirely. It's used for executing Recordset.Seek
commands for recordsets opened with CommandType = adCmdTableDirect
and using a server-side cursor. If you print Recordset.Supports(adIndex)
, you will note your recordset doesn't support it after opening. Setting an unsupported property can either raise an error or just do nothing in ADO.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments