Hi all i have difficulty writing each row of listview to mysql db. I be happy if some one help me fix it.Thanks



VB Code:
  1. Private Sub Command11_Click()
  2.  Dim CNN As ADODB.Connection
  3. Set CNN = New ADODB.Connection
  4. CNN.Open "DRIVER={MySQL ODBC 3.51 Driver};SERVER=localhost;DATABASE=visualbasic6;USER=root;PASSWORD=;OPTION=3;"
  5.  
  6.  
  7.  Dim sSQL As String
  8. Dim i As Long
  9. For i = 1 To ListView1.ListItems.Count
  10.     sSQL = "INSERT INTO musictest (url,songname,artist,album) "
  11.     sSQL = sSQL & " VALUES('" & ListView1.ListItems.Item(i).Text & "', '"
  12.     sSQL = sSQL & " " & ListView1.Subitems(1) &  ', '"
  13.     sSQL = sSQL & " & ListView1.Subitems(2) &  ', '"
  14.     sSQL = sSQL & " & ListView1.Subitems(3) &  ', '"
  15.    
  16.     MsgBox sSQL
  17.     'etc
  18.     CNN.Execute sSQL
  19. Next
  20.      
  21. MsgBox " The songs are inserted to database successfully"
  22. End Sub


and points to :CNN.Execute sSQL

i printed out the sql and the url field was used corectly but not the rest:




I even tried this and got error:


VB Code:
  1. sSQL = sSQL & " VALUES('" & ListView1.ListItems.Item(i).Text & "','" & ListView1.SubItems(1) & "','" & ListView1.SubItems(2) & "', '" & ListView1.SubItems(3) & "')"

VB Code:
  1. Compile error:
  2.  
  3. Method or data member not found

pointing at :.SubItems

could u help me fix this.thanks