自己已经连接到数据库了!给大家分享一下:
但首先要在工具中引用ADO两个MADO2.7 LIBRARY和MADOR2.8 LIBRARY
Public Sub ADOTest1()
Dim cnn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim strCnn As String
Dim i As Long
strCnn = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & ThisWorkbook.Path & "\evapor.mdb;"
cnn.Open strCnn
rs.Open "Select * From Evapor", cnn, adOpenForwardOnly, adLockReadOnly
i = 1
Do Until rs.EOF
Cells(i, 1).Value = rs.Fields("ET").Value
Cells(i, 2).Value = rs.Fields("EP").Value
Cells(i, 3).Value = rs.Fields("Ev").Value
Cells(i, 4).Value = rs.Fields("Eh").Value
Cells(i, 5).Value = rs.Fields("Er").Value
i = i + 1
rs.MoveNext
Loop
rs.Close
cnn.Close
End Sub
[[it] 本帖最后由 sami_szl 于 2008-7-5 15:42 编辑 [/it]]
[[it] 本帖最后由 sami_szl 于 2008-7-5 18:31 编辑 [/it]]