using ADO with SQL database - locking issues

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I have VBA code running in AutoCAD 2015. I have a connection string that points to a database on a SQL Server. When I define the recordset do I really need to set the LockType and CursorType? I am having some database locking problems reported by end users. Multiple users are using the VBA code and I am wondering if setting the LockType and CursorType is really necessary and maybe that is the culprit. SQL should handle that automatically for me right? The LockType and CursorType exist in the code because the database was formerly MS Access and it was never removed when we migrated to a SQL database. Can anyone help?
EXAMPLE CODE SNIPPET WITH CURSORTYPE AND LOCKTYPE DEFINED
con.Open ConnectionString
Set rec = New ADODB.Recordset
With rec
.ActiveConnection = con
.CursorType = adOpenStatic
.LockType = adLockPessimistic
End With
rec.Open "Select * From [MetalStuff].[wallstuff].[WALLPIECES]"
Do While Not rec.EOF
If IsNull(rec("releaseNum")) Then
rec("releaseNum") = ""
rec.Update
End If
rec.MoveNext
Loop
rec.Close
con.Close