Results 1 to 4 of 4

Thread: [Resolved]Trouble Inserting record into table.

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2001
    Location
    Maumelle, AR
    Posts
    624

    Angry [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:
    1. 'connect to the database
    2. Dim Cnn As ADODB.Connection
    3. Dim SQL As String
    4. Set Cnn = New ADODB.Connection
    5. Cnn.Open ConnectionString:="Provider=Microsoft.Jet.OLEDB.4.0;" & _
    6.       "Data Source= c:\windows\system\kamo.mdb;"
    7.  
    8. 'set table = to the category added
    9. table = txtcategory.Text
    10.  
    11. 'Loop through the filelistbox getting info on the files
    12. MusicMaster.File1.Path = txtpath.Text
    13. On Error Resume Next
    14. For x = 0 To MusicMaster.File1.ListCount - 1
    15.     fname = MusicMaster.File1.Path & "\" & MusicMaster.File1.List(x)
    16.     Call ReadMP3(fname, True, True)
    17.    
    18. 'Store the MP3 info as strings
    19.     strFilepath = fname
    20.     strFileName = MusicMaster.File1.List(x)
    21.     strFileSize = FileLen(fname)
    22.     strArtist = GetMP3Info.Artist
    23.     strTitle = GetMP3Info.Songname
    24.     strAlbum = GetMP3Info.Album
    25.     strTrack = GetMP3Info.Track
    26.     strFrequency = GetMP3Info.Frequency
    27.     strBitrate = GetMP3Info.Bitrate
    28.     strLength = GetMP3Info.Duration
    29.    
    30.    
    31. 'Use SQL to insert the information in the strings into the table
    32. 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 & "')"
    33.  
    34. Next   'do the same thing for each item in the filelistbox
    35.  
    36.  
    37. 'Update the combocategory on the main form
    38. Call WriteTextFile  'this is irrelevant to the SQL stuff- Igore it.
    Last edited by hipopony66; Apr 6th, 2002 at 12:27 AM.

  2. #2
    Member
    Join Date
    Mar 2002
    Location
    Cleveland, OH
    Posts
    33
    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

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2001
    Location
    Maumelle, AR
    Posts
    624

    Angry Still Not adding records!

    Ok, I added that line, but it's still not adding any records to my table!

  4. #4

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2001
    Location
    Maumelle, AR
    Posts
    624
    ^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
  •  



Click Here to Expand Forum to Full Width