public SQLCnn as adodb.connection
public AdoRs as adodb.recordset
Private Function Conexion() As Boolean
Set SQLCnn = CreateObject("adodb.connection")
SQLCnn.Provider = "sqloledb"
SQLCnn.Properties("user ID") = ""
SQLCnn.Properties("password") = ""
SQLCnn.Properties("integrated security") = "SSPI"
SQLCnn.Properties("persist security info") = False
SQLCnn.Properties("data source") = "SQL-SERVER"
SQLCnn.Properties("initial catalog") = AppBD
SQLCnn.CursorLocation = adUseServer
Call SQLCnn.Open
Conexion=CBool(SQLCnn.State = 1)
End Function
public sub Consulta()
'Abre un recordset de sólo lectura.
Set AdoRsE = CreateObject("adodb.recordset")
Set AdoRsE.ActiveConnection = SQLCnn
AdoRsE.CursorLocation = adUseServer
AdoRsE.CursorType = adOpenForwardOnly
AdoRsE.LockType = adLockReadOnly
Call AdoRsE.Open("Select * from tabla o vista")
If AdoRsE.State = 1 Then
'Visualiza los registros.
While Not AdoRsE.EOF
...
Call AdoRsE.MoveNext
DoEvents
Wend
End If
end
Si tienes más dudas utiliza mi correo
un saludo mari