View Single Post
  #2 (permalink)  
Old May 17th, 2006, 10:51 AM
woodyz woodyz is offline
Friend of Wrox
 
Join Date: May 2006
Location: San Diego, CA, USA.
Posts: 643
Thanks: 0
Thanked 0 Times in 0 Posts
Default

In your first sample it appears you have several problems:

1 - The syntax is incorrect for working with a listview
2 - Your use of quotes in building the string is incorrect

The code should look more like this:


Code:
Private Sub Command1_Click()

    Dim sSQL As String     
    Dim i As Long
    Dim item As ListItem    ' Here is the listitem you need to work with

    For i = 1 To ListView1.ListItems.Count
        Set item = ListView1.ListItems(i)
        sSQL = "INSERT INTO musictest (url,songname,artist,album) "
        sSQL = sSQL & " VALUES('" & item.Text & "', '"
        sSQL = sSQL & item.SubItems(1) & "', '"
        sSQL = sSQL & item.SubItems(2) & "', '"
        sSQL = sSQL & item.SubItems(3) & "')"

        Debug.Print sSQL
    Next

End Sub
Of course, you will have to put your data access code back in - I removed it for clarity.

I hope that helps

Woody Z http://www.learntoprogramnow.com
Reply With Quote