rs.Open "update Prehens set PRE_VCSPOW='" & Trim(Text2.Text) & " ' where ID='" & Text1.Text & "'", conn, adOpenStatic, adLockOptimistic
If Val(Text1.Text) > 0 Then
MsgBox "成功上传数据", 64, "成功"
Else
If Val(Text1.Text) = 0 Then
MsgBox "请输入编号", 48, "警告"
End If
End If
text1输入的是ID,当输入的ID不正确或者不存在,还是显示上传成功,请问如何判断?好象要用eof和bof 什么的,但是我不知道怎么+进去!

解决方案 »

  1.   

    rs.Open "select count(*) as count_t from Prehens where ID='" & Text1.Text & "'", conn, adOpenStatic, adLockOptimistic
    if rs!count_t>0 then
       if rs.state then rs.close'如果打开着就关闭它
       rs.Open "update Prehens set PRE_VCSPOW='" & Trim(Text2.Text) & " ' where ID='"  & Text1.Text & "'", conn, adOpenStatic, adLockOptimistic
         MsgBox "成功上传数据", 64, "成功"
    else
        MsgBox "请输入编号", 48, "警告"
     
    End If