大家帮我看看这短代码,一执行就死

xylcyc 2004-08-23 11:06:28
Dim rsItem As New ADODB.Recordset
Dim rsBody As New ADODB.Recordset

Dim strsql As String
Dim nodeX As Node

rsBody.CursorType = adOpenKeyset
rsBody.LockType = adLockOptimistic
rsBody.ActiveConnection = CnnDB
rsItem.CursorType = adOpenKeyset
rsItem.LockType = adLockOptimistic
rsItem.ActiveConnection = CnnDB

CmbModel1.Visible = False
CmbModel1.Nodes.Clear

If rsBody.State = adStateOpen Then rsBody.Close
rsBody.Open "select * from stdbodypart"
While Not rsBody.EOF
If Trim(rsBody!bodypart_name) = Trim(CmbBodyPart.Text) Then
Set nodeX = CmbModel1.Nodes.Add(, tvwNext, "BKey" & rsBody!bodypart_key, Trim(rsBody!bodypart_name & ""))
strsql = "select * from stdclininfo where bodypart_key=" & rsBody!bodypart_key
If rsItem.State = adStateOpen Then rsItem.Close
rsItem.Open strsql
While Not rsItem.EOF
CmbModel1.Nodes.Add nodeX.key, tvwChild, , rsItem!ix_code & ""
rsItem.MoveNext
Wend
rsBody.MoveNext
End If
Wend

CmbModel1.Visible = True
...全文
69 5 点赞 打赏 收藏 举报
写回复
5 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
落伍者 2004-08-23
无限循环了,按照上面改下好了
  • 打赏
  • 举报
回复
vbman2003 2004-08-23
While Not rsBody.EOF
  if......then
......
End if
rsBody.MoveNext
Wend
  • 打赏
  • 举报
回复
LGYAN 2004-08-23
rsBody.MoveNext不应该放在IF条件之内
  • 打赏
  • 举报
回复
starsoulxp 2004-08-23
rsBody.MoveNext 应该写在end if的下面。
  • 打赏
  • 举报
回复
starsoulxp 2004-08-23
While Not rsBody.EOF
If Trim(rsBody!bodypart_name) = Trim(CmbBodyPart.Text) Then
Set nodeX = CmbModel1.Nodes.Add(, tvwNext, "BKey" & rsBody!bodypart_key, Trim(rsBody!bodypart_name & ""))
strsql = "select * from stdclininfo where bodypart_key=" & rsBody!bodypart_key
If rsItem.State = adStateOpen Then rsItem.Close
rsItem.Open strsql
While Not rsItem.EOF
CmbModel1.Nodes.Add nodeX.key, tvwChild, , rsItem!ix_code & ""
rsItem.MoveNext
Wend
rsBody.MoveNext '如果第2行的if条件不满足,岂不是无法退出循环了???
End If
Wend
  • 打赏
  • 举报
回复
相关推荐
发帖

1188

社区成员

VB 数据库(包含打印,安装,报表)
申请成为版主
帖子事件
创建了帖子
2004-08-23 11:06
社区公告
暂无公告