删除数据问题!

游子 2010-08-22 06:06:57
Dim strSQL As String
Dim myBookmark As Variant
Dim cnn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim str2 As String
rs.LockType = adLockOptimistic
rs.CursorType = adOpenKeyset
cnn.CursorLocation = adUseClient
cnn.ConnectionString = connstr
cnn.Open
rs.Open "SELECT * FROM to_repeat where yz_date between' " + Str(DTPicker1.Value) + "' and '" + Str(DTPicker2.Value) + "' order by yz_date", cnn
str2 = MsgBox("确定要删除查询到的数据?", vbOKCancel, "提示")
If str2 = vbOK Then
If (DTPicker1.Value <> "") Then
rs.Delete
rs.MoveNext
MsgBox "删除成功", vbOKOnly + vbInformation, "提示"
rs.Close
Set cnn = Nothing
End If
End If
为什么只删除一条数据呢??明明查到N条啊。。
...全文
39 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
fzx4936 2010-08-22
  • 打赏
  • 举报
回复
哦 上面的rs.MoveNext要注释掉
fzx4936 2010-08-22
  • 打赏
  • 举报
回复

If str2 = vbOK Then
If (DTPicker1.Value <> "") Then
Do While not rs.eof
rs.Delete
rs.MoveNext
loop
end if
end if

7,763

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧