|
-
Apr 30th, 2002, 02:30 PM
#1
Thread Starter
Fanatic Member
Hmm..This is odd. Need some help.
I'm using the SQL below to add information about files in a filelistbox to a table. On certain groups of files it works great, but on others, it gives an error "Syntax Error in Insert Into Statement". Why would this work on some files and not others? They are all Mp3 I am dealing with. Any help is extremely appreciated. I don't understand this one. Here's the code:
VB Code:
'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) 'THE ERROR OCCURS ON THIS LINE
Next
-
Apr 30th, 2002, 02:35 PM
#2
strArtist and strTitle are probably blank on the ones it is failing.
You need to detect that and insert NULL into the database instead of ""
Need to re-register ASP.NET?
C:\WINNT\Microsoft.NET\Framework\v#VERSIONNUMBER#\aspnet_regiis -i
(Edit #VERSIONNUMBER# as needed - do a DIR if you don't know)
-
Apr 30th, 2002, 02:51 PM
#3
Thread Starter
Fanatic Member
hmmm...
Where would be the best place to detect that? When it reads the tag first and have 2 separate SQL Statements? Or is there a way to insert NULL if the field is blank?
-
Apr 30th, 2002, 02:52 PM
#4
Thread Starter
Fanatic Member
Well that's not the problem
All of my files have ID3 v1 tags. So the Artist and Title fields are always >0. Any other ideas?
-
Apr 30th, 2002, 02:55 PM
#5
Another though.
Do you have the following characters in any of them?
" & | #
Need to re-register ASP.NET?
C:\WINNT\Microsoft.NET\Framework\v#VERSIONNUMBER#\aspnet_regiis -i
(Edit #VERSIONNUMBER# as needed - do a DIR if you don't know)
-
Apr 30th, 2002, 03:57 PM
#6
Thread Starter
Fanatic Member
Yes I do.......
Some filenames contain "&" (i.e. Huey Lewis & The News)
-
Apr 30th, 2002, 04:38 PM
#7
Your problem is probably that there is a space in one or more of the fields. To get around that problem put "[" and "]" around the field names in the SQL.
-
Apr 30th, 2002, 04:47 PM
#8
Thread Starter
Fanatic Member
Can you give an example?
I think I did what you said, but I'm still getting the error, can you give an example of what you meant?
-
Apr 30th, 2002, 04:54 PM
#9
I think this is correct but I don't have time to test it. Change all variable names like the following.
('[" & Replace(strFilepath, "']", "''")
-
Apr 30th, 2002, 05:17 PM
#10
The characters I listed are reserved characters for SQL. You should consider escaping them.
In this Thread:
http://www.vbforums.com/showthread.p...hreadid=166453
Kira posted a good example of how to do that.
Need to re-register ASP.NET?
C:\WINNT\Microsoft.NET\Framework\v#VERSIONNUMBER#\aspnet_regiis -i
(Edit #VERSIONNUMBER# as needed - do a DIR if you don't know)
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
|