Results 1 to 10 of 10

Thread: Hmm..This is odd. Need some help.

  1. #1

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

    Question 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:
    1. 'Use SQL to insert the information in the strings into the table
    2. SQL = "INSERT into " & table _
    3. & "(FilePath, Filename, Filesize, Artist, Title) VALUES ('"_
    4.  & Replace(strFilepath, "'", "''")_
    5.  & "','" & Replace(strFileName, "'", "''") _
    6. & "','" & Replace(strFileSize, "'", "''") _
    7. & "','" & Replace(strArtist, "'", "''") & "','" _
    8. & Replace(strTitle, "'", "''") & "')"
    9.  
    10. Cnn.Execute (SQL) 'THE ERROR OCCURS ON THIS LINE
    11.  
    12. Next

  2. #2
    C# Aficionado Lord_Rat's Avatar
    Join Date
    Sep 2001
    Location
    Cave
    Posts
    2,497
    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)

  3. #3

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

    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?

  4. #4

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

    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?

  5. #5
    C# Aficionado Lord_Rat's Avatar
    Join Date
    Sep 2001
    Location
    Cave
    Posts
    2,497
    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)

  6. #6

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

    Yes I do.......

    Some filenames contain "&" (i.e. Huey Lewis & The News)

  7. #7

  8. #8

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

    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?

  9. #9

  10. #10
    C# Aficionado Lord_Rat's Avatar
    Join Date
    Sep 2001
    Location
    Cave
    Posts
    2,497
    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
  •  



Click Here to Expand Forum to Full Width