Hi Guys,
I have just installed SQL server and I'm trying to work out how to connect an access frontend to tables in my server (MS Sql Server 2000). I found this code that should connect the customers form of Northwind and the tables in the Server but I am getting an error message saying:
Run-time error '2147467259 (800004005)':
[DBNETLIB}{ConnectionOpen (ParseConnectParams()).]Invalid connection.
this is the code I got from the microsoft site except for the path to the server that I put in:
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 = "C:\Program Files\Microsoft SQL Server"
.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
Can anyone help me get started with this.
I have just installed SQL server and I'm trying to work out how to connect an access frontend to tables in my server (MS Sql Server 2000). I found this code that should connect the customers form of Northwind and the tables in the Server but I am getting an error message saying:
Run-time error '2147467259 (800004005)':
[DBNETLIB}{ConnectionOpen (ParseConnectParams()).]Invalid connection.
this is the code I got from the microsoft site except for the path to the server that I put in:
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 = "C:\Program Files\Microsoft SQL Server"
.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
Can anyone help me get started with this.