|
-
Apr 5th, 2002, 03:41 PM
#1
Thread Starter
Fanatic Member
[Resolved]Trouble Inserting record into table.
Hey, I can create my table in my database and everthing else, but I'm having trouble inserting the records. Can someone tell me what's wrong here? I don't get any errors, but when I open the table in Access, there are no records. Here's my code:
VB Code:
'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
On Error Resume Next
For x = 0 To MusicMaster.File1.ListCount - 1
fname = MusicMaster.File1.Path & "\" & MusicMaster.File1.List(x)
Call ReadMP3(fname, True, True)
'Store the MP3 info as strings
strFilepath = fname
strFileName = MusicMaster.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 & "')"
Next 'do the same thing for each item in the filelistbox
'Update the combocategory on the main form
Call WriteTextFile 'this is irrelevant to the SQL stuff- Igore it.
Last edited by hipopony66; Apr 6th, 2002 at 12:27 AM.
-
Apr 5th, 2002, 04:00 PM
#2
Member
It appears you build the SQL string, but never execute it
'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 'do the same thing for each item in the filelistbox
-
Apr 5th, 2002, 04:06 PM
#3
Thread Starter
Fanatic Member
Still Not adding records!
Ok, I added that line, but it's still not adding any records to my table!
-
Apr 5th, 2002, 11:36 PM
#4
Thread Starter
Fanatic Member
^bump^
I think there is an error in my SQL. Seems to be the only thing it could be! Anyone???
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
|