Double apostrophes

  • I guess this is probably the right place for this, if not, please forgive me.

     

    I have some code that is Doing an update.  this code is in a COM object.  The apostrophes are being escaped, the only thing is, that when 1 apostrophe is replaced with two, two seem to be entered into te DB.  Is there something in SQL, or ADODB that is handling this for me?  heres the code:

     

    ContID = Val(Web.Session("contentid"))

        strContent = Web.Request.Form("Content")

        ContentName = Web.Request.Form("Headline")

        ArticleDesc = Web.Request.Form("ArticleDesc")

        

            

            

            strSql = "UPDATE Content SET ContentName = '" & vstr(ContentName) & "', Content = '" & vstr(strContent) & "', ArticleDesc = '" & vstr(Web.Request.Form("ArticleDesc")) & "', LastUpdated = '" & Date & "', Dateposted='" & sdateposted & "', ThumbnailWidth = " & sThumbnailWidth & ", ThumbnailAlignment = '" & Web.Request("ThumbnailAlign") & "', Topnews=" & stopnews

            objConn.Execute strSql

     

    The vstr is simply a findand replace for ' to ''

     

    What on earth am I doing wrong. 

     

    If content = john's  I get john''s when I pull it out of the DB.

     

    Thanks for any insight.

  • Can you post vstr?

    Usually there exists a function Replace in Asp, ...

  • Private Function vstr(strString)

        strString = Trim(strString)

        strString = Replace(strString, "'", "''")

        vstr = strString

    End Function

     

    This is not my code, it's the code of my predecessor.  So my first thought was that vstr was being called multiple times on the same strings, but that is not the case .. just an FTYI.  Thanks

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply