我编写一段高考成绩查询系统,运行时提示:'实时错误91,对象变量或with或块变量未设置",请问如何解决?,谢谢
Private Sub Adodc1_WillMove(ByVal adReason As ADODB.EventReasonEnum, adStatus As ADODB.EventStatusEnum, ByVal pRecordset As ADODB.Recordset)
End Sub
Private Sub Form_Load()
ado.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + App.Path + "\db1.mdb"
ado.CommandType = adCmdText
ado.RecordSource = "select * from db1"
ado.Refresh '程序运行至此,出现出错提示"对象的方法IAdodc失败"
End Sub
Private Sub Label2_Click()
ado.Recordset.Close '程序运行至此,出现出错提示"实时错误91,对象变量或with或块变量未设置"
ado.Recordset.Open "select * from db1 where 准考证号= ' " + Txt1 + "’' "
If ado.Recordset.EOF Then
MsgBox "数据库中没有你想查询的", 16, "错误" Else
Form2.Txt1.Text = ado.Recordset.Fields(" 姓名" ).Value
Form2.Txt2.Text = ado.Recordset.Fields("性别").Value
Form2.Txt3.Text = ado.Recordset.Fields("语文").Value
Form2.Txt4.Text = ado.Recordset.Fields("数学").Value
Form2.Txt5.Text = ado.Recordset.Fields("英语").Value
Form2.Txt6.Text = ado.Recordset.Fields("综合").Value
Form2.Txt7.Text = ado.Recordset.Fields("总分").Value
Form2.Txt8.Text = ado.Recordset.Fields("录取学校").Value
Form2.Show
Form2.Caption = RTrim(ado.Recordset.Fields("姓名").Value) & "的成绩"
End If
End Sub