做查询的时候,遇到一个问题,每次查询没有结果显示,却总把数据库里的数据给修改了,郁闷呀!求救!
我用的是adodc控件绑定的数据库,代码如下:
Private Sub CancelButton_Click()
   Dim intcount As Integer
   For intcount = 0 To 15
       Text1(intcount).Text = ""
   Next intcount
End SubPrivate Sub Check1_Click(Index As Integer)
   If Index = 0 Then
        Text1(0).SetFocus
   ElseIf Index = 1 Then
        Text1(1).SetFocus
   ElseIf Index = 2 Then
        Text1(2).SetFocus
   ElseIf Index = 3 Then
        Text1(3).SetFocus
   End If
End SubPrivate Sub Command1_Click(Index As Integer)
   If Index = 0 Then
        Adodc1.Recordset.MoveFirst
   ElseIf Index = 1 Then
        Adodc1.Recordset.MoveLast
   ElseIf Index = 2 Then
        Adodc1.Recordset.MovePrevious
        If Adodc1.Recordset.BOF Then
              Adodc1.Recordset.MoveLast
        End If
   ElseIf Index = 3 Then
        Adodc1.Recordset.MoveNext
        If Adodc1.Recordset.EOF Then
            Adodc1.Recordset.MoveFirst
        End If
   ElseIf Index = 4 Then
        frmBook.Show
        Unload Me
   ElseIf Index = 5 Then
        Unload Me
   End If
End SubPrivate Sub Form_Load()
   Me.ZOrder 0
   Adodc1.Refresh
'   For intcount = 0 To 3
'     Text1(intcount) = ""
'  Next intcount
  'Text1(0).SetFocus
End SubPrivate Sub OKButton_Click()
     Dim s As String
     
     If Check1(0).Value = 0 And Check1(0).Value = 0 And Check1(0).Value = 0 And Check1(0).Value = 0 Then
          MsgBox "请选择查询标准", vbOKOnly, "提示"
          Exit Sub
     End If
     
     If Check1(0).Value = 1 Then
        s = "name= '" & Trim(Text1(0) & " ") & "'"
     ElseIf Check1(1).Value = 1 Then
        s = "zuozhe= '" & Trim(Text1(1) & " ") & "'"
     ElseIf Check1(2).Value = 1 Then
        s = "fenleihao= '" & Trim(Text1(2) & " ") & "'"
     ElseIf Check1(3).Value = 1 Then
         s = "chubanshe= '" & Trim(Text1(3) & " ") & "'"
     End If
     Adodc1.Recordset.Find s
     
     If Adodc1.Recordset.EOF = True Then
     MsgBox "对不起,您查找的记录不存在", vbOKOnly, "提示"
     End If
End Sub

解决方案 »

  1.   

    我试了,是执行adodc1.recordset.find s的时候改的
    那程序应该怎么改啊
      

  2.   

    好象书名本来是vb,然后我想查java
    执行的时候vb那条记录的书名就改成java了
      

  3.   

    我怀疑根本没有改变什么,是查到了你需要的记录:)也就是说,你有两条记录,差别只是所查字段一个为“VB”,另一个为“JAVA”,你改查“JAVA”,它调出了“JAVA”那条记录。你可以打开数据库看看是不是这样 。你最好编辑一个主键,判断其主键是不是同一个就知道了。
      

  4.   

    “查询结果都不显示在右边文本框的”,你的代码里没有给那个“右边的文本框”赋值,即使查到了也不可能显示!改如下:    Adodc1.Recordset.Find s
         
        If Adodc1.Recordset.EOF = True Then
           MsgBox "对不起,您查找的记录不存在", vbOKOnly, "提示"
        else
           Text2.text = Acodc1.Recordset.Fields("Name")
        End If
      

  5.   

    非常对不起,我犯了个低级错误,文本框跟跟adodc连了