Public Function daadfa()
'必须引用 ado --------- Microsoft ActiveX Date Objects X.X Library
Dim conn As New ADODB.Connection, connstr As String, db As String, rs As New ADODB.Recordset, i As Long, rows As Long
db = "C:\adb2.mdb"
connstr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & db
conn.Open connstr
rs.Open "select * from 表1", conn, 1, 3
If rs.EOF And rs.BOF Then
MsgBox "无记录"
Else
rows = 1
For i = 0 To rs.Fields.Count - 1
Worksheets("Sheet2").Cells(1, rows).Value = rs.Fields(i).Name
Next i
Do Until rs.EOF
For i = 0 To rs.Fields.Count - 1
Worksheets("Sheet2").Cells(i + 2, rows).Value = rs(i)
Next i
rows = rows + 1
rs.MoveNext
Loop
End If
End Function