vba 查询access
使用软件office2010
工具-引用-activex 2.8
.xls 等类型文件
On Error GoTo ErrorHandler
Dim Conn As New ADODB.Connection
Conn.Open "Provider=Microsoft.ACE.OLEDB.12.0;extended properties=excel 12.0;Data Source =" & tempfile1 & ";" 'csv、xls,xlsx等文件
Dim rs As New ADODB.Recordset
strSQL=“[excel 12.0;DATABASE=?noCardMember].[sheet8$]” xls,xlsx等文件
strSQL=”select * from [TEXT;FMT=CSV;DELIMITED;HDR=YES;DATABASE=" & 路径& "].表名.csv ” csv文件
rs.Open strSQL, Conn, adOpenKeyse
Do While Not rs.EOF
preArrStr(1) = rs("aaa")
rs.MoveNext
Loop
Close #1
rs.Close
conn.close