Results 1 to 6 of 6

Thread: Using strings in SQL statement.....

  1. #1

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

    Using strings in SQL statement.....

    Hey, I resolved my adding records problem, but I need to fix this last error. Rikk gave me a tip on how to do this, but I keep getting the error. It has to do with the strings containing the '.
    I changed the SQL to REPLACE the ' with ''. Here's what I've got:
    VB Code:
    1. SQL = "INSERT into " & table & " VALUES ('" & Replace(strFilepath, "'", "''") & "','" & Replace(strFileName, "'", "''") & "','" & Replace(strFileSize, "'", "''") & "','" & Replace(strArtist, "'", "''") & "','" & strTitle & "','" & Replace(strAlbum, "'", "''") & "','" & Replace(strFrequency, "'", "''") & "','" & Replace(strBitrate, "'", "''") & "','" & Replace(strLength, "'", "''") & "','" & Replace(strTrack, "'", "''") & "')"
    2. Cnn.Execute (SQL)

  2. #2
    sunnyl
    Guest
    Isn't it mean to be " (one Chr(34)) and not ' ' (two Chr(39)s)?

  3. #3

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

    Can't do that

    You get an unexpected separator syntax error.

  4. #4
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    What is the error you are getting?

    I see your query string is all text type.
    How about your field types in the SQL table?
    Are they all text type too?

    I forgot that there is in SQL, a setting for the single quote or something like that.

  5. #5

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

    Here's how my columns are set up...

    VB Code:
    1. ' Create a new Table object.
    2.    With tbl
    3.       .Name = categories.txtcategory.Text
    4.       ' Create fields and append them to the new Table
    5.       ' object. This must be done before appending the
    6.       ' Table object to the Tables collection of the
    7.       ' Catalog.
    8.       .Columns.Append "FilePath", adVarWChar
    9.       .Columns.Append "FileName", adVarWChar
    10.       .Columns.Append "Filesize", adVarWChar
    11.       .Columns.Append "Artist", adVarWChar
    12.       .Columns.Append "Title", adVarWChar
    13.       .Columns.Append "Album", adVarWChar
    14.       .Columns.Append "Frequency", adVarWChar
    15.       .Columns.Append "Bitrate", adVarWChar
    16.       .Columns.Append "Length", adVarWChar
    17.       .Columns.Append "Track#", adVarWChar
    18.      
    19.    End With

  6. #6

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

    ^bump^

    n/m

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