如果你的tid字段是数字类型的,那么下面这句有错误
Set List = conn.Execute("select * from books where tid=" & rs("id") & "")改成
Set List = conn.Execute("select * from books where tid=" & rs("id"))
Set List = conn.Execute("select * from books where tid=" & rs("id") & "")改成
Set List = conn.Execute("select * from books where tid=" & rs("id"))
解决方案 »
- 无法修改collection中元素的值,为什么?
- 如何实现这样查询顺丰单号
- 怎么比较两个word文档的区别,主要是文字。
- .Recordset.Fields.Count到底是什么的数目???????
- msHFlexgrid 控件 调整列宽 并保存各列宽值
- 如何使一个无边框的平面窗体通过拖曳窗体的四边界来改变窗体的大小,另外如何改变边框的颜色?
- 有关SQL Server数据库的备份与恢复
- DataReport是否可以实现打印经条件筛选后的数据?
- 关于源代码!
- 怎么在vb里调用帮助文件?
- 有一难题???求高手指教!!!
- 关于文件读写程序,我还是运行不过去,而且这程序是书上抄的,希望大家一起来帮忙。
改成不用List作为ADODB.Recordset,换一个名字,例如ListItems
opdb
dim ListItems as ADODB.Recordset
set ListItems = new ADODB.RecordsetSet rs = conn.Execute("select * from type")
If Not rs.EOF Then
While Not rs.EOF
tv1.Nodes.Add , , rs("tname"), rs("tname")
Set ListItems = conn.Execute("select * from books where tid=" & rs("id"))
If Not ListItems.EOF Then
While Not ListItems.EOF
tv1.Nodes.Add rs("tname"), tvwChild, ListItems("title"), ListItems("title")
ListItems.MoveNext
Wend
Else
tv1.Nodes.Add rs("tname"), tvwChild, "error", "没有资料卡片"
End If
ListItems.Close
Set ListItems = Nothing
rs.MoveNext
Wend
Else
tv1.Nodes.Add , , "error", "没有分类"
End If
要知道List是控件名字,你用了set List = xxx当然错了,将List改为别的名字就没有错了,就算错,也是你的程序本身有错了。
下面是用index调试成功的代码:
Set rs = conn.Execute("select * from type")
i = 1
If Not rs.EOF Then
While Not rs.EOF
tv1.Nodes.Add , 1, , rs("tname")
Set ListItem = conn.Execute("select * from books where tid=" & rs("id"))
r = i
While Not ListItem.EOF
tv1.Nodes.Add i, 4, ListItem("title"), ListItem("title")
ListItem.MoveNext
r = r + 1
Wend
i = r
ListItem.Close
Set ListItem = Nothing
rs.MoveNext
i = i + 1
Wend
Else
tv1.Nodes.Add , 1, , "没有分类"
End If
TreeView.Refresh
Dim I As Integer
Dim j As Integer For I = 1 To 6
TreeImages.ListImages.Add , , TreeImage(I).Picture '增加图片
Next I
TreeView.ImageList = TreeImages
Set factory = TreeView.Nodes.Add(, , "f 总公司", "总公司", 1, 4) '设置总公司
factory.Expanded = True
Set Rs = New ADODB.Recordset
strSQL = "select distinct Department from BaseInfo"
Rs.Open strSQL, Conn, adOpenDynamic, adLockBatchOptimistic
With Rs
If Not .EOF And Not .BOF Then
DepCount = .RecordCount
Do While Not .EOF
Set group = TreeView.Nodes.Add(factory, tvwChild, j & .Fields(0).value, .Fields(0).value, 2, 4)
depName(j) = .Fields(0).value
j = j + 1
.MoveNext
Loop
Else
depName(j) = ""
End If
End With
只作参考
Set rs = conn.Execute("select * from type")
If Not rs.EOF Then
While Not rs.EOF
tv1.Nodes.Add , , rs("tname"), rs("tname")
Set List = conn.Execute("select * from books where tid=" & rs("id") & "")
If Not List.EOF Then
While Not List.EOF
tv1.Nodes.Add rs("tname"), tvwChild, List("title"), List("title")'提示这里出错 ,你的问题可能在结点的key不唯一
List.MoveNext
Wend
Else
tv1.Nodes.Add rs("tname"), tvwChild, "error", "没有资料卡片" '如果有两种类型的
书没有资料卡片,key为error的结点会添加两次。
End If
List.Close
Set List = Nothing
rs.MoveNext
Wend
Else
tv1.Nodes.Add , , "error", "没有分类"
End If那位帮我看看是怎么回事啊?提示说invaild object
tv1.Nodes.Add rs("tname"), tvwChild, List("title"), List("title")
将它改为:
tv1.Nodes.Add rs("tname").value, tvwChild, List("title"), List("title")
就行了