|
-
Apr 4th, 2002, 08:59 PM
#1
Thread Starter
Fanatic Member
Need help finding error in code here...
The error occurs on the following line:
VB Code:
For x = 0 To File1.ListCount - 1
Here's the code:
VB Code:
Private Sub Command2_Click()
'Dim stuff here
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
For x = 0 To File1.ListCount - 1
fname = File1.Path & "\" & File1.List(x)
ReadMP3 fname, True, True
'Store the info as strings
strFilepath = fname
strFileName = File1.List(x)
strFileSize = FileLen(fname)
strArtist = GetMP3Info.Artist
strTitle = GetMP3Info.Songname
strAlbum = GetMP3Info.Album
strTrack = GetMP3Info.Track
strFrequency = GetMP3Info.Frequency
strBitrate = GetMP3Info.bitrate
strLength = GetMP3Info.Duration
'Use SQL to insert the information in the strings into the table
SQL = "INSERT into Table (Filepath,Filename,Filesize,Artist, _
Title,Album,Frequency,Bitrate,Length,Track#) _
VALUES ('" & strFilepath & "','" & strFileName & "', _
'" & strFileSize & "','" & strArtist & "','" & strTitle & "', _
'" & strAlbum & "','" & strTrack & "','" & strFrequency & "', _
'" & strBitrate & "','" & strLength & "')"
Cnn.Execute SQL
Next
'Update the combocategory on the main form
Call WriteTextFile
End Sub
-
Apr 4th, 2002, 09:12 PM
#2
Addicted Member
What is the error?
-
Apr 4th, 2002, 09:28 PM
#3
Addicted Member
Rikk =\=
Starcraft, Protoss Scout Driver!
-
Apr 4th, 2002, 09:31 PM
#4
Thread Starter
Fanatic Member
Fixed that....New Error :)
I forgot to specify the File1.Path=! 
Now I'm getting an error on SQL Insert part. On this Line:
And yes I know that in the post the SQL line is messed up, but I made it so you wouldn't have to scroll over. I think the problem is:
TABLE in this line is a variable, not the name of the table I want to open. Should I have it in quotes or something? I have to do this because the table name will vary.
-
Apr 4th, 2002, 09:34 PM
#5
Addicted Member
Rikk =\=
Starcraft, Protoss Scout Driver!
-
Apr 4th, 2002, 09:35 PM
#6
Addicted Member
Yep, you will
ie:
VB Code:
Dim myTable as String
Dim SQL as String
myTable="WhateverTable"
SQL = "INSERT into " & myTable & " the rest....."
-
Apr 4th, 2002, 09:57 PM
#7
Thread Starter
Fanatic Member
SQL syntax error on that last line I posted
-
Apr 5th, 2002, 07:39 AM
#8
Addicted Member
Beware of inserting data like this:
VB Code:
VALUES ('" & strFilepath & "','" & strFileName & "'
If the strFilePath var contains a single quote in it, it will fail. Use REPLACE on EVERY var to change all single quotes to two single quotes. It will go in the database as only one.
Like this...
VB Code:
VALUES ('" & Replace(strFilepath,"'","''") & "','" & Replace(strFileName,"'","''") & "'
Rikk =\=
Starcraft, Protoss Scout Driver!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|