To make the connection you can implement it in a module something like:
Attribute VB_Name = "Conexion"
Option Explicit
Public cn As ADODB.Connection
Public rs As ADODB.Recordset
Public Sub Conectar()
Set cn = New ADODB.Connection
Set rs = New ADODB.Recordset
rs.CursorLocation = adUseClient
cn.Open "Provider=SQLNCLI11;Server=.;Database=DBPrueba;Uid=sa;Pwd=666;"
End Sub
Public Sub Desconectar()
On Error Resume Next
rs.Close
Set rs = Nothing
cn.Close
Set cn = Nothing
End Sub
Using this connection
Server=myServerAddress;Database=myDataBase;User Id=myUsername;
Password=myPassword;
You can follow SQL Serverver 2000 connection strings
You can use it from a Client Class:
Public Function GetCliente() As ADODB.Recordset
Dim rs As ADODB.Recordset
Dim strSQL As String
Conectar
strSQL = "SELECT idCliente AS Código, nombre AS Nombre FROM Clientes"
Set rs = New ADODB.Recordset
rs.Open strSQL, cn, adOpenStatic, adLockOptimistic
Set GetCliente = rs
End Function
The code is example you must adapt it to your needs.