Dim strSql As String
strSql = "select FirstName from dbo.Employees"
Set conn = New ADODB.Connection
Set rs = New ADODB.Recordset
conn.ConnectionString = "Provider=SQLOLEDB.1;Password=sa;Persist Security Info=True;User ID=sa;Initial Catalog=Northwind;Data Source=127.0.0.1"
conn.Open
With rs
.CursorLocation = adUseClient
.CursorType = adOpenForwardOnly
.LockType = adLockReadOnly
.ActiveConnection = conn
.Open strSql
End With
Set GetData = rs
Set conn = Nothing
Set rs = Nothing
End Function