Ms Access, ADODB, Recordset, Set Primarykey

testo

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?

Erik A

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.

edited at
0

Comments

0 comments
Login to comment

Related

MS Access ListBox column property with ADODB Recordset creates error 424 Object Required

access violation inside ADODB recordset Close

Filtering a MS-Access recordset based on records in another recordset

ADODB find on a recordset

Edit records in ADODB recordset

MS access copying recordset using vba

Modify a query recordset to complete information (MS Access)

Access VBA set recordset of lists not working

Unable to open ADODB recordset (with password)

Output ADODB.RecordSet as JSON

Add data to ADODB Recordset dynamically

Use database with linked tables in Access 2000 or use the ADODB.RecordSet - Which is better?

access [object Array of Byte] objectGUID value from ADODB.Recordset for an Active Directory query

Really deleting entries of MS Access database with ADODB command

Create an linked Table from an ADODB.Connection in Ms Access

MS Access - ADODB conection issue - syntax error in FROM clause

MS Access Visual Basic Group Recordset and modify values

Looping through a recordset to output Ms-Access report to a pdf file

Cannot retrieve recordset returned from stored procedure in MS Access ADO

VBA in MS Access: how to accelerate a loop operation on a recordset

MS Access - how can i aggregate two queries in one recordset?

MS ACCESS VBA recordset search criteria type mismatch

Insert Complete RecordSet to another table in other database MS Access

MS Access Recordset Moving on Search even if no match found?

trying to compare data in one recordset to the column name of another MS Access

Running two SQL queries in VBA MS Access. The second recordset depends on the first recordset

ADODB.Connection & ADODB.Recordset - User define type not defined

Change language for ADODB.Recordset or ADODB.Connection

Error setting VBA Recordset of form from ADODB.recordset