''' 假如我们有一个CUSTOMER.dbf 在C:\ 后
''' NOTE: This subroutine requires that you reference the
''' latest version of the following library:
'''
''' Microsoft ActiveX Data Objects Library
Dim conn As ADODB.Connection
Dim rst As ADODB.Recordset
'
Dim i As Integer
' Create the Connection object.
Set conn = New ADODB.Connection
PathToDatabase = "c:\"
With conn
'Assign the connection string to the connection object.
.ConnectionString = "DRIVER={Microsoft dBase Driver (*.dbf)};" & _
"DBQ=" & PathToDatabase & ";" & _
"DefaultDir=" & PathToDatabase & "\"
' Open the connection.
.Open strConn
End With
' Create a new Recordset Object.
Set rst = New ADODB.Recordset
With rst
' Connect this recordset to the previously opened connection.
.ActiveConnection = conn
' Retrieve all records from the Customer table.
.Open "SELECT * FROM Customer"
End With
' 由此得出DBF 数据集。
Set rst = Nothing
' Close the Connection.
conn.Close
改自微软实例 HAMLETL
[此贴子已经被作者于2003-7-17 12:12:02编辑过]
|