这样的错误如何解决?
编了个数据库查询代码,运行后提示“自动化错误”,实时错误为“-214702469(8007007f)",代码如下请高手纠错!
Dim adoConn As ADODB.Connection
Dim adoRes As ADODB.Recordset
Dim nameCount As Integer
Private Sub Command1_Click()
Unload Me
End Sub
Private Sub Command2_Click()
Dim strSel As String
Dim newItem As ListItem
ListView1.ListItems.Clear
If Trim(Text1.text) = "" Then
MsgBox "请输入查询内容!", 6, "提示!"
Exit Sub
End If
nameCount = 0
strSel = "select * from addrBook where Name like '" + Trim(Text1.text) + "%'"
adoRes.Open strSel, adoConn, , , adCmdText
Do While Not adoRes.EOF
Set newItem = ListView1.ListItems.Add
newItem.text = adoRes!Name
newItem.SubItems(1) = adoRes!jobaddr
newItem.SubItems(2) = adoRes!Phone
newItem.SubItems(5) = adoRes!birth
newItem.SubItems(6) = adoRes!Type
newItem.SubItems(7) = adoRes!code
newItem.SubItems(8) = adoRes!job
newItem.SubItems(4) = adoRes!mobile
newItem.SubItems(3) = adoRes!email
adoRes.MoveNext
nameCount = nameCount + 1
Loop
adoRes.Close
If nameCount = 0 Then
Command1.Enabled = True
Else
End If
End Sub
Private Sub Form_Activate()
Text1.SetFocus
End Sub
Private Sub Form_Load()
Dim strCon As String
nameCount = 0
strCon = App.Path
If Right(strCon, 1) = "\" Then
strCon = strCon + "myAPP.mdb"
Else
strCon = strCon + "\myAPP.mdb"
End If
'打开数据库连接
strCon = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + strCon
Set adoConn = New ADODB.Connection
adoConn.Open strCon
Set adoRes = New ADODB.Recordset
End Sub