Loop dictionary with multiple records

I filled an dictionary with values from an xml source like this
For items As Integer = 1 To root.ChildCount-1 'we start with 1 because the first xml element is the element
itemsNode = root.Child(items)
For item As Integer = 0 To itemsNode.ChildCount-1
itemNode = itemsNode.Child(item)
For subItem As Integer = 0 To itemNode.ChildCount-1
if (itemNode.Child(subItem).ChildCount > 0) Then
key = itemNode.Child(subItem).LocalName
value = itemNode.Child(subItem).FirstChild.Value
dim d as new dictionary
d.Value(“key”) = key
d.Value(“value”) = value
data.Append(d) 'scope = global
End
// leeg relatie database

  Next
Next

Next

for example :
name=Ronald
lastname=stolk
NEXT RECORD
name=Friso
lastname=Stolk

how can i loop the dictionary per record to create an sql insert

sql=“INSERT INTO relaties SET "
For each element as dictionary in data
sql = sql + element.Value(“key”)+”=’"+element.Value(“value”)+"’," END AFTER EACH RECORD

next

Hi Ronald,

You can use something like this:

[code] Dim keys() As Variant = dico.Keys
Dim inserts() As String

For each key As Variant in Keys()

inserts.Append key.StringValue + "='" + dico.Value(key).StringValue + "'"

Next

Dim sql As String = "Insert into TABLE set " + Join(inserts, “,”)[/code]

Hi Jeremie

it works :wink: