Results 1 to 6 of 6

Thread: Key Not Unique [Resolved]

Threaded View

  1. #1

    Thread Starter
    Member
    Join Date
    Jun 2003
    Location
    Georgia
    Posts
    32

    Key Not Unique [Resolved]

    I get a Key not Unique error message when I add a record to a parent node without a child node, but when I add a record to a parent node that already has a child it works.

    VB Code:
    1. Private Sub initializeTree()
    2.     tvwItems.ImageList = imgList
    3.    
    4.     Dim nodClass As Node
    5.     Dim nodTitle As Node
    6.    
    7.     tvwItems.LineStyle = tvwRootLines
    8.     tvwItems.Nodes.Clear
    9.    
    10.     'Initialize the recordsets
    11.     Set rsClass = New ADODB.Recordset
    12.     Set rsTitle = New ADODB.Recordset
    13.  
    14.     'Open the Class recordset
    15.     strSQLClass = "SELECT id, classification FROM tblClassification ORDER BY classification"
    16.     rsClass.Open strSQLClass, conTree, adOpenStatic, adLockOptimistic
    17.    
    18.     'set node for treeview
    19.     If rsClass.RecordCount > 0 Then
    20.         While Not rsClass.EOF
    21.             Set nodClass = tvwItems.Nodes.Add(, , (rsClass.Fields("classification")), (rsClass.Fields("classification")), 1)
    22.  
    23.             'Opens the recordset for Title
    24.             strSQLTitle = "SELECT id, title, classification, code, dateadded FROM tblSnipplets WHERE classification LIKE '" & (rsClass.Fields("classification")) & "%'"
    25.             rsTitle.Open strSQLTitle, conTree, adOpenStatic, adLockOptimistic
    26.            
    27.             'set node for treeview
    28.             If rsTitle.RecordCount > 0 Then
    29.                 While Not rsTitle.EOF
    30.                     Set nodTitle = tvwItems.Nodes.Add((rsClass.Fields("classification")), tvwChild, CStr(rsTitle.Fields("id")) & " id", (rsTitle.Fields("title")), 2)
    31.                   '  Set nodTitle = tvwItems.Nodes.Add
    32.                    
    33.                     nodTitle.Tag = rsTitle.Fields("Id").Value
    34.                     rsTitle.MoveNext
    35.                     DoEvents
    36.                 Wend
    37.             End If
    38.             rsTitle.Close
    39.            
    40.             rsClass.MoveNext
    41.             DoEvents
    42.         Wend
    43.     End If
    44.     rsClass.Close
    45. End Sub
    Last edited by odamsr; Apr 11th, 2004 at 11:15 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width