Sub getdata()
Dim objRec As New ADODB.Recordset
Dim CONN As New ADODB.Connection
CONN.Open "DSN=server;UID=ID;PWD=password"
CONN.CommandTimeout = 0
Dim xselect As String
xselect = " SELECT * From Emp;"
objRec.Open xselect, CONN
Range("A2").CopyFromRecordset objRec
objRec.Close
CONN.Close
End Sub
|