vb删除记录的问题

来源:百度知道 编辑:UC知道 时间:2024/09/22 09:30:43
Call sjk(conn)
sqlstr = "select * from ydgl" ' where 编号='" & Val(txtLbdj(0).Text) & "'"
RS2.Open sqlstr, conn, adOpenDynamic, adLockBatchOptimistic
RS2.Delete
RS2.UpdateBatch
RS2.Close
MsgBox ("ok!")
conn.Close
End If
这样做会提示eof或bof为真的错误
conn.Execute ("delect from ydgl where 编号='" & Val(txtLbdj(0).Text) & "'")
这样做会提示语法错误,实时错误,-2147217900,from附近有语法错误
是哦
这个与错了都不注意到,第一个加判断是什么意思
if RS2.eof then 这样就是没有记录了,我怎么删除啊

if RS2.eof then
RS2.Delete
RS2.UpdateBatch
end if
RS2.Close
第一个加上判断即可。
第二个
conn.Execute ("delect from ydgl where 编号='" & Val(txtLbdj(0).Text) & "'") 你的delete 写错了。