A
Alan Z. Scharf
Hi,
I'm trying to set up a separate ADO connection for a form's recordset.
I've used the example in KB /281998, but am getting above error message at
the point of the .Open method.
Can anyone spot what I am doing wrong?
Note: The application first opens with the following connection: It is the
separate ADO connection for a form that I'm having trouble with, even though
I used the same connection values as in conncet string below.
rovider=Microsoft.Access.OLEDB.10.0;Persist Security Info=True;Data
Source=GRAPEVINE2;Integrated Security=SSPI;Initial Catalog=Marketing;Data
Provider=SQLOLEDB.1
Thanks.
Alan
Code for separate Form connection in OnOpen event
------------------------------------------------------
Private Sub Form_Open(Cancel As Integer)
Dim cnn As ADODB.Connection
Dim rst As ADODB.Recordset
'Create a new ADO Connection object
Set cnn = New ADODB.Connection
'Use the Access 10 and SQL Server OLEDB providerst to
'open the Connection
With cnn
.Provider = "Microsoft.Access.OLEDB.10.0"
.Properties("Data Provider").Value = "SQLOLEDB"
.Properties("Data Source").Value = "GRAPEVINE2"
.Properties("Persist Security Info").Value = "True"
.Properties("Integrated Security").Value = "SPPI"
.Properties("Initial Catalog").Value = "Marketing"
.Open
End With
'Create an instance of the ADO Recordset class, and
'set its properties
Set rst = New ADODB.Recordset
With rst
Set .ActiveConnection = cnn
.Source = ("SELECT * FROM dbo.tblCalculationResults")
' .LockType = adLockOptimistic
' .CurstorType = adOpenKeyset
.Open
End With
'Set the form's Recordset property to the ADO recordset
Set Me.Recordset = rst
Set rst = Nothing
Set cnn = Nothing
End Sub
I'm trying to set up a separate ADO connection for a form's recordset.
I've used the example in KB /281998, but am getting above error message at
the point of the .Open method.
Can anyone spot what I am doing wrong?
Note: The application first opens with the following connection: It is the
separate ADO connection for a form that I'm having trouble with, even though
I used the same connection values as in conncet string below.
rovider=Microsoft.Access.OLEDB.10.0;Persist Security Info=True;Data
Source=GRAPEVINE2;Integrated Security=SSPI;Initial Catalog=Marketing;Data
Provider=SQLOLEDB.1
Thanks.
Alan
Code for separate Form connection in OnOpen event
------------------------------------------------------
Private Sub Form_Open(Cancel As Integer)
Dim cnn As ADODB.Connection
Dim rst As ADODB.Recordset
'Create a new ADO Connection object
Set cnn = New ADODB.Connection
'Use the Access 10 and SQL Server OLEDB providerst to
'open the Connection
With cnn
.Provider = "Microsoft.Access.OLEDB.10.0"
.Properties("Data Provider").Value = "SQLOLEDB"
.Properties("Data Source").Value = "GRAPEVINE2"
.Properties("Persist Security Info").Value = "True"
.Properties("Integrated Security").Value = "SPPI"
.Properties("Initial Catalog").Value = "Marketing"
.Open
End With
'Create an instance of the ADO Recordset class, and
'set its properties
Set rst = New ADODB.Recordset
With rst
Set .ActiveConnection = cnn
.Source = ("SELECT * FROM dbo.tblCalculationResults")
' .LockType = adLockOptimistic
' .CurstorType = adOpenKeyset
.Open
End With
'Set the form's Recordset property to the ADO recordset
Set Me.Recordset = rst
Set rst = Nothing
Set cnn = Nothing
End Sub