Dim rs As New ADODB.Recordset
sql = "Select * From [sunglasses]"
Set rs = getrs(sql, "Products")
If Not rs.EOF Then
TreeView1.Nodes.Clear
'If rs.RecordCount > 0 Then’这个判断省了也没关系
For I = 1 To rs.RecordCount
If Not IsExistNode("MYKEY_" & Trim(rs.Fields("省")), TreeView1) Then
TreeView1.Nodes.Add , , "MYKEY_" & Trim(rs.Fields("省")), rs.Fields("省")
End If
'少了个判断项,检查市没有的话在省下添加市
If Not IsExistNode("MYKEY_" & Trim(rs.Fields("市")), TreeView1) Then
TreeView1.Nodes.Add "MYKEY_" & Trim(rs.Fields("省")), tvwChild, "MYKEY_" & Trim(rs.Fields("市")), rs.Fields("市")
End If
'在市下添加县
TreeView1.Nodes.Add "MYKEY_" & Trim(rs.Fields("市")), tvwChild, "R" & I, rs.Fields("县")
rs.MoveNext
Next
rs.Close
'End If
End If
Set rs = Nothing