|
-
Apr 5th, 2002, 04:24 PM
#1
Thread Starter
Fanatic Member
SQL Insert not adding records to my table!
I can create the table fine, but the records are not being added to my table. Can someone tell me why? Here's the code:
VB Code:
'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
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 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 & "')"
Cnn.Execute (SQL)
Next 'Loop through getting info and adding a record for each item in the filelistbox.
-
Apr 5th, 2002, 08:27 PM
#2
Hyperactive Member
Humm. What is your error? Also I see the connection object but no recordset object.
-
Apr 5th, 2002, 09:32 PM
#3
Fanatic Member
he doesnt need a recordset object
-
Apr 5th, 2002, 10:45 PM
#4
Hyperactive Member
True. He doesn't say if there is an error. Could be the database has a password. Could be the SQL is wrong. Could be just about anything.
-
Apr 5th, 2002, 11:30 PM
#5
Thread Starter
Fanatic Member
There is no error
I don't get an error, and the database I created is not pw protected. I'm guessing it's a problem with my SQL. The values I am entering are strings. Can someone give me some help with the SQL part? I thought the code seemed pretty clear to understand. Let me know if you need more info.
-
Apr 5th, 2002, 11:37 PM
#6
Hyperactive Member
The fields you are trying to insert could be the wrong size and/or type. Double check that. You can also try printing out your SQL string, copying the text, and moving it over to Access. You can then test the SQL statement using a query and see if it is working.
-
Apr 6th, 2002, 01:48 AM
#7
Hyperactive Member
now ive found sum1 with d same problm.
but mine do has an error and sumtimes dont. the problem is the string, or the vars that contains the string has {'} in it. and sometimes {.} or simply punctuations. when i tried to omit those punctuations from the source, strings/vars, the Execute method workd fine.
so our question might be, or should be...
what is the correct INSERT INTO statement if the string contains punctuations?
-
Apr 6th, 2002, 01:53 AM
#8
Fanatic Member
ahhh, i had this same problem a while back, had me totally stumped all day! i went the dodgey option and just didnt allow any '
hehe
but what u have to do is use forward slash then the '
like
/'
means '
i THINK, someone told me that a while back, i never used it, so i could be totally wrong, worth a try though.
(and if u want a forward slash use //)
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
|