S
Scott Lichtenberg
I have been using the technique shown below to create forms bound to SQL
server tables and views using ADODB recordsets. It works so well that it
seems almost too good to be true.
My major concern is whether using ADODB recordsets will lead to deadlock
problems on the SQL server? Even though I have closed the connection object
and the original recordset object, the recordset, which is now bound to the
form's recordset property, remains open as long as the form is.
What happens if a user opens a form, thereby loading data into the form's
recordset property, then decides to go to lunch, leaving the form open? My
company has about 100 users, so it is likely that one or more of them would
try to query, or even edit records in the out-to-lunch user's open form.
I'm led to believe that ADODB creates a disconnected recordset, so there
shouldn't be any issues. However, I would really like to hear this from
someone who actually knows how this works.
Thanks in advance for any help.
Scott
==========
KB Article ID Q281998
How to bind Microsoft Access forms to ADO recordsets
Private Sub Form_Open(Cancel As Integer)
Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
'Create a new ADO Connection object
Set cn = New ADODB.Connection
'Use the Access 10 and SQL Server OLEDB providers to
'open the Connection
'You will need to replace MySQLServer with the name
'of a valid SQL Server
With cn
.Provider = "Microsoft.Access.OLEDB.10.0"
.Properties("Data Provider").Value = "SQLOLEDB"
.Properties("Data Source").Value = "MySQLServer"
.Properties("User ID").Value = "sa"
.Properties("Password").Value = ""
.Properties("Initial Catalog").Value = "NorthwindCS"
.Open
End With
'Create an instance of the ADO Recordset class, and
'set its properties
Set rs = New ADODB.Recordset
With rs
Set .ActiveConnection = cn
.Source = "SELECT * FROM Customers"
.LockType = adLockOptimistic
.CursorType = adOpenKeyset
.Open
End With
'Set the form's Recordset property to the ADO recordset
Set Me.Recordset = rs
Set rs = Nothing
Set cn = Nothing
End Sub
server tables and views using ADODB recordsets. It works so well that it
seems almost too good to be true.
My major concern is whether using ADODB recordsets will lead to deadlock
problems on the SQL server? Even though I have closed the connection object
and the original recordset object, the recordset, which is now bound to the
form's recordset property, remains open as long as the form is.
What happens if a user opens a form, thereby loading data into the form's
recordset property, then decides to go to lunch, leaving the form open? My
company has about 100 users, so it is likely that one or more of them would
try to query, or even edit records in the out-to-lunch user's open form.
I'm led to believe that ADODB creates a disconnected recordset, so there
shouldn't be any issues. However, I would really like to hear this from
someone who actually knows how this works.
Thanks in advance for any help.
Scott
==========
KB Article ID Q281998
How to bind Microsoft Access forms to ADO recordsets
Private Sub Form_Open(Cancel As Integer)
Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
'Create a new ADO Connection object
Set cn = New ADODB.Connection
'Use the Access 10 and SQL Server OLEDB providers to
'open the Connection
'You will need to replace MySQLServer with the name
'of a valid SQL Server
With cn
.Provider = "Microsoft.Access.OLEDB.10.0"
.Properties("Data Provider").Value = "SQLOLEDB"
.Properties("Data Source").Value = "MySQLServer"
.Properties("User ID").Value = "sa"
.Properties("Password").Value = ""
.Properties("Initial Catalog").Value = "NorthwindCS"
.Open
End With
'Create an instance of the ADO Recordset class, and
'set its properties
Set rs = New ADODB.Recordset
With rs
Set .ActiveConnection = cn
.Source = "SELECT * FROM Customers"
.LockType = adLockOptimistic
.CursorType = adOpenKeyset
.Open
End With
'Set the form's Recordset property to the ADO recordset
Set Me.Recordset = rs
Set rs = Nothing
Set cn = Nothing
End Sub