Hi !
I want to use an Access database for my VB 6.0 multi-user app.
Here is the big picture of my problem !!
This is my connection to an Access database.
This is the way I open a recordsetCode:Dim conAccess As ADODB.Connection Dim strConnectionString as String Set conAccess = New ADODB.Connection strConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\TestDB.mdb;" conAccess.Open strConnectionString
The problem with that is my whole table is locked and not only the 3 records selected. How can I have only my selected records (my recordset) locked.Code:Dim rstRecord as ADODB.Recordset Dim strSQL as String Set rstRecord = New ADODB.Recordset strSQL = "SELECT * FROM MYTABLE WHERE ..MYCONDITIONS.." '( lets say it returns 3 records ) rstRecord.Open strSQL, conAccess, adOpenForwardOnly, adLockPessimistic 'Now .. i need to lock those records until that recordset is closed. 'The only way I found to do that is this line: rstRecord(0) = rstRecord(0) 'It is kind of an Edit 'rstRecord.CancelUpdate allows me to unlock the data (see update below to view how I use it)
Also, I don't feel I am doing this the best way. I feel my Edit technique is a turn around and not the proper way to do it.
And my updates are made this way.
Please help me !!Code:Dim strSQL as String strSQL = "UPDATE TABLE MYTABLE SET FIELD = VALUE, FIELD1 = VALUE1, FIELD2 = VALUE2 WHERE MY CONDITIONS ..." 'Unlock and Update rstRecord.CancelUpdate conAccess.Execute strSQL
Don't send me MSDN text explaining Lock Types and blabla... I read that stuff already.
I need code exemple or hints that YOU used and that worked.




Reply With Quote