using ado:First. Uses menu 'Project | Reference' to add Microsoft Active Data Object Library reference.Second.dim cnn as new ADODB.Connection
dim rst as new ADODB.Recordset    Dim UserName As String
    Dim Password As String
    Dim ServerName As String
    Dim DBName As String
    
    UserName = "sa"    'Login User here
    Password = ""    'login password here
    ServerName = "YourServerName"  'the name of your server that running SQL Server here
    DBName = "Northwind" 'specifing the database here
    
    ' Set connection properties.
    cn.ConnectionTimeout = 25                                       ' Set the time out.
    cn.Provider = "sqloledb"                                        ' Specify the OLE DB provider.
    cn.Properties("Data Source").Value = ServerName                 ' Set SQLOLEDB connection properties.
    cn.Properties("Initial Catalog").Value = DBName                 ' Set SQLOLEDB connection properties.
    cn.Properties("Integrated Security").Value = "SSPI"             ' Set SQLOLEDB connection properties.
        
    ' Open the database.
    cn.Open
                      
    ' Open the Recordset.
    rs.Open "select * from Employees", cn, adOpenKeyset, adLockPessimistic'do the work code here....