Private Sub Command2_Click()
'Dim stuff here
Dim Tag As String * 3
Dim Songname As String * 30
Dim Artist As String * 30
Dim Album As String * 30
Dim Year As String * 4
Dim Comment As String * 30
Dim Genre As String * 1
Dim x As Integer
Dim table As String
Dim fname As String
Dim strFilepath As String, strFileName As String, _
strFileSize As String, strArtist As String, _
strTitle As String, strAlbum As String, strTrack As String, _
strFrequency As String, strBitrate As String, _
strLength As String
'add the new category to the listbox
lstCategories.AddItem txtcategory.Text
'Create a new table in the Database for the category
Call ADOCreateTable
'connect to the database
Dim Cnn As ADODB.Connection
Dim SQL As String
Set Cnn = New ADODB.Connection
Cnn.Open ConnectionString:="Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source= c:\windows\system\kamo.mdb;"
'set table = to the category added
table = txtcategory.Text
'Loop through the filelistbox getting info on the files
MusicMaster.File1.Path = txtpath.Text
For x = 0 To MusicMaster.File1.ListCount - 1
fname = MusicMaster.File1.Path & "\" & MusicMaster.File1.List(x)
Filename = fname
'Read ID3v1 Tags
Open Filename For Binary As #1
Get #1, FileLen(Filename) - 127, Tag
If Not Tag = "TAG" Then
Close #1
HasTag = False
End If
HasTag = True
Filename = Filename
Get #1, , Songname
Get #1, , Artist
Get #1, , Album
Get #1, , Year
Get #1, , Comment
Get #1, , Genre
Close #1
'''''''''end of reading file''''''''''''''''''
'Store the info as strings
strFilepath = fname
strFileName = MusicMaster.File1.List(x)
strFileSize = FileLen(fname)
strTitle = RTrim(Songname)
strArtist = RTrim(Artist)
'Use SQL to insert the information in the strings into the table
SQL = "INSERT into " & table &_
"(FilePath, Filename, Filesize, Artist, Title) VALUES ('" & Replace(strFilepath, "'", "''") _& "','" _
& Replace(strFileName, "'", "''") & "','" _
& Replace(strFileSize, "'", "''") & "','" _
& Replace(strArtist, "'", "''") & "','" _
& Replace(strTitle, "'", "''") & "')"
Cnn.Execute (SQL) 'ERROR OCCURS HERE
Next