|
Sub tt()
On Error GoTo err_tag
Dim con As New ADODB.Connection
Dim rec As New ADODB.Recordset
rec.Open "select zl,mph from mzfw", CurrentProject.Connection, adOpenDynamic, adLockOptimistic, adCmdText
rec.MoveFirst
While Not rec.EOF
Dim str As String
Dim str2 As String
Dim arr() As String
str = rec.Fields("zl")
str2 = rec.Fields("mph")
Debug.Print str, str2
rec.MoveNext
rec.Close
con.CloseWend
err_tag:
MsgBox "df" '为什么总是运行么这里,是不是还要注意什么事项
Exit Sub
Exit Sub
End Sub
如果是在Access里执行,请留意粗体部分的位置。如果是在Excel里运行,这一句可能要改改:con.Open "provider=microsoft.jet.oledb.4.0;data source=d:\1111111111111.MDB", "", "", -1
具体的链接字符串请自行查找下。 |
|