nameld001 发表于 2011-4-13 13:54:12

请问这个代码哪里错了

代码如下:附件放到D盘根目录就可以帮测试了,我老是找不出原因,希望大家帮帮忙。
Sub tt()
On Error GoTo err_tag
Dim con As New ADODB.Connection
Dim rec As New ADODB.Recordset
con.Open "provider=microsoft.jet.oledb.4.0;data source=d:\1111111111111.MDB", "", "", -1
rec.Open "select zl,mph from mzfw", con, adOpenDynamic, adLockOptimistic, adCmdText
rec.MoveFirst
While Not rec.EOF
Dim str As String
Dim str2 As String
Dim arr() As String
Debug.Print
str = rec.Fields("zl")
str2 = rec.Fields("mph")
rec.MoveNext
Wend
err_tag:
MsgBox "df" '为什么总是运行么这里,是不是还要注意什么事项
Exit Sub
rec.Close
con.Close
Exit Sub
End Sub

wylong 发表于 2011-4-13 15:01:02

本帖最后由 wylong 于 2011-4-13 15:02 编辑

Sub tt()
On Error GoTo err_tag
Dim con As New ADODB.Connection
Dim rec As New ADODB.Recordset
con.Open "provider=microsoft.jet.oledb.4.0;data source=d:\1111111111111.MDB", "", "", -1
rec.Open "select zl,mph from mzfw", con, adOpenDynamic, adLockOptimistic, adCmdText
rec.MoveFirst
While Not rec.EOF
Dim str As String
Dim str2 As String
Dim arr() As String
Debug.Print
str = rec.Fields("zl")
str2 = rec.Fields("mph")
rec.MoveNext
Wend
rec.Close
con.Close
Exit Sub
err_tag:
MsgBox "df"
End Sub
页: [1]
查看完整版本: 请问这个代码哪里错了