Well actually it is an SQL statement, but it does contradict itself. It work perfectly while looping through certain folders of files, but gives "Error in INSERT INTO STATEMENT" error. on another folder. All folders contain MP3 files. So why in hell does it create the correct table for one folder and won't work for the other folder? I've posted my code below.
This is the code that calls a sub to build a table and then adds the info on the files to the table.
VB Code:
  1. Private Sub Command2_Click()
  2. 'Dim stuff here
  3. Dim Tag As String * 3
  4. Dim Songname As String * 30
  5. Dim Artist As String * 30
  6. Dim Album As String * 30
  7. Dim Year As String * 4
  8. Dim Comment As String * 30
  9. Dim Genre As String * 1
  10. Dim x As Integer
  11. Dim table As String
  12. Dim fname As String
  13. Dim strFilepath As String, strFileName As String, _
  14. strFileSize As String, strArtist As String, _
  15. strTitle As String, strAlbum As String, strTrack As String, _
  16. strFrequency As String, strBitrate As String, _
  17. strLength As String
  18.  
  19.  
  20. 'add the new category to the listbox
  21. lstCategories.AddItem txtcategory.Text
  22.  
  23. 'Create a new table in the Database for the category
  24. Call ADOCreateTable
  25.  
  26. 'connect to the database
  27. Dim Cnn As ADODB.Connection
  28. Dim SQL As String
  29. Set Cnn = New ADODB.Connection
  30. Cnn.Open ConnectionString:="Provider=Microsoft.Jet.OLEDB.4.0;" & _
  31.       "Data Source= c:\windows\system\kamo.mdb;"
  32.  
  33. 'set table = to the category added
  34. table = txtcategory.Text
  35.  
  36. 'Loop through the filelistbox getting info on the files
  37. MusicMaster.File1.Path = txtpath.Text
  38.  
  39. For x = 0 To MusicMaster.File1.ListCount - 1
  40.     fname = MusicMaster.File1.Path & "\" & MusicMaster.File1.List(x)
  41.     Filename = fname
  42. 'Read ID3v1 Tags
  43. Open Filename For Binary As #1
  44.     Get #1, FileLen(Filename) - 127, Tag
  45.     If Not Tag = "TAG" Then
  46.     Close #1
  47.     HasTag = False
  48.        
  49.         End If
  50.         HasTag = True
  51.     Filename = Filename
  52.     Get #1, , Songname
  53.     Get #1, , Artist
  54.     Get #1, , Album
  55.     Get #1, , Year
  56.     Get #1, , Comment
  57.     Get #1, , Genre
  58.     Close #1
  59. '''''''''end of reading file''''''''''''''''''
  60.    
  61. 'Store the info as strings
  62.     strFilepath = fname
  63.     strFileName = MusicMaster.File1.List(x)
  64.     strFileSize = FileLen(fname)
  65.     strTitle = RTrim(Songname)
  66.     strArtist = RTrim(Artist)
  67.    
  68.    
  69.    
  70. 'Use SQL to insert the information in the strings into the table
  71. SQL = "INSERT into " & table &_
  72.  "(FilePath, Filename, Filesize, Artist, Title) VALUES ('" & Replace(strFilepath, "'", "''") _& "','" _
  73. & Replace(strFileName, "'", "''") & "','" _
  74. & Replace(strFileSize, "'", "''") & "','" _
  75. & Replace(strArtist, "'", "''") & "','" _
  76. & Replace(strTitle, "'", "''") & "')"
  77.  
  78.  
  79. Cnn.Execute (SQL)  'ERROR OCCURS HERE
  80.  
  81. Next
This is the code that in the sub that builds the table:
VB Code:
  1. Sub ADOCreateTable()
  2.  
  3.    Dim cat As New ADOX.Catalog
  4.    Dim tbl As New ADOX.table
  5.  
  6.    ' Open the catalog
  7.    cat.ActiveConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
  8.       "Data Source= c:\windows\system\kamo.mdb;"
  9.  
  10.    ' Create a new Table object.
  11.    With tbl
  12.       .Name = categories.txtcategory.Text
  13.       ' Create fields and append them to the new Table
  14.       ' object. This must be done before appending the
  15.       ' Table object to the Tables collection of the
  16.       ' Catalog.
  17.       .Columns.Append "FilePath", adVarWChar
  18.       .Columns.Append "FileName", adVarWChar
  19.       .Columns.Append "Filesize", adVarWChar
  20.       .Columns.Append "Artist", adVarWChar
  21.       .Columns.Append "Title", adVarWChar
  22.    End With
  23.  
  24.    ' Add the new table to the database.
  25.    cat.Tables.Append tbl
  26.  
  27.    Set cat = Nothing
  28.    
  29.    
  30.  
  31. End Sub
Any help is extremely appreciated. This doesn't make any sense to me.