I need help to evaluate 'best practice' on the following issue:
I'm converting a system from accdb to Sql Server. Sql Tables are Linked to the frontend, using odbc driver. Several users may access the system via separate front-ends for each user.
From time to time, me or the user(s) need to update a big portion of records, and on those routines, I have a habit to do following:
Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset
rs.Activeconnection = CurrentProject.Connection
Dim newValue A String
newValue = "some info to be updated"
rs.Open "SELECT dbo_Table.Value, xxxxx FROM dbo_Table", , adOpenKeyset, adLockOptimistic 'xxxxx = other fields to be updated
Do While Not rs.EOF
rs!Value = newValue
'xxxxx other fields to be updated
rs.Update
rs.MoveNext
Loop
rs.Close
The question her (for me at least) is the usage of acLockOptimistic. Because, on several occasion, other user may access one of the record in a form and have it in 'edit mode' when other may run the update mentioned above. So, my question is - how to set the correct rs.open "xxx",, ?, ? values, or - how to avoid 'run-time errors' or something similar?
Secondly - How to convert the above setup - from Dim rs As... to rs.Close to Transaction SQL usage?
I have study the T-Sql theory, and understand much of it, but I'm getting a little lost in the 'With rs.cnn do...' when most of my table updates are made based on similar setup as above. I ask for help on this, because I believe this can also be the solution (at least partly) on the first question.
If someone could 'translate' the above table setup to include T-Sql with error trap on my concern, I will be forever thankful
If the above have been asked and answered so clearly that I want/need, please excuse me for posting this.
I have tried to search, but may have searched the wrong way because I haven't found it...
Thank you for your time!
Best regards,
Geirr E.
I'm converting a system from accdb to Sql Server. Sql Tables are Linked to the frontend, using odbc driver. Several users may access the system via separate front-ends for each user.
From time to time, me or the user(s) need to update a big portion of records, and on those routines, I have a habit to do following:
Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset
rs.Activeconnection = CurrentProject.Connection
Dim newValue A String
newValue = "some info to be updated"
rs.Open "SELECT dbo_Table.Value, xxxxx FROM dbo_Table", , adOpenKeyset, adLockOptimistic 'xxxxx = other fields to be updated
Do While Not rs.EOF
rs!Value = newValue
'xxxxx other fields to be updated
rs.Update
rs.MoveNext
Loop
rs.Close
The question her (for me at least) is the usage of acLockOptimistic. Because, on several occasion, other user may access one of the record in a form and have it in 'edit mode' when other may run the update mentioned above. So, my question is - how to set the correct rs.open "xxx",, ?, ? values, or - how to avoid 'run-time errors' or something similar?
Secondly - How to convert the above setup - from Dim rs As... to rs.Close to Transaction SQL usage?
I have study the T-Sql theory, and understand much of it, but I'm getting a little lost in the 'With rs.cnn do...' when most of my table updates are made based on similar setup as above. I ask for help on this, because I believe this can also be the solution (at least partly) on the first question.
If someone could 'translate' the above table setup to include T-Sql with error trap on my concern, I will be forever thankful
If the above have been asked and answered so clearly that I want/need, please excuse me for posting this.
I have tried to search, but may have searched the wrong way because I haven't found it...
Thank you for your time!
Best regards,
Geirr E.