揭西县棉湖镇天气:vb 高手吗? 请进!

来源:百度文库 编辑:杭州交通信息网 时间:2024/04/27 23:34:31
Private Sub cmdseek_Click()
If Text1.Text = "" Then
MsgBox "请输入要查找的学号!"
Text1.SetFocus
End If
If Text1.Text <> "" Then
Adodc1.Recordset.MoveFirst
Adodc1.Recordset.Find (学号 = Text1.Text)
If Adodc1.Recordset.EOF Then
MsgBox "没有找到次学号的学生!", , "查找信息"
Adodc1.Recordset.MoveFirst
End If
End If
End Sub

我用的是SQL2000数据库,上面的代码是实现一个查找功能,如果“Text1.Text”输入的学号。可是一运行系统提示“实时错误‘3001’
参数类型不真确,或不在可以接受的范围之内,或与其他参数冲突”。请问我该怎么办?主要是“Adodc1.Recordset.Find (学号 = Text1.Text)
”这一句出错。

代码修改如下:
Private Sub cmdseek_Click()
If Text1.Text = "" Then
MsgBox "请输入要查找的学号!"
Text1.SetFocus
End If
If Text1.Text <> "" Then
Adodc1.Recordset.MoveFirst
Adodc1.Recordset.Find ("学号 = '" & Text1.Text & "'")
If Adodc1.Recordset.EOF Then
MsgBox "没有找到此学号的学生!", , "查找信息"
Adodc1.Recordset.MoveFirst
End If
End If

End Sub

可能你学号字段的类型不是字符型.