Apostophe not Accepting

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • nitindel
    New Member
    • Dec 2007
    • 67

    Apostophe not Accepting

    Hi all,
    Greetings..!!

    I am using ASP VB script and SQL Server 2005 on Backend...

    I have taken the Text as a datatype....

    But when we submit the form it is not entering APSOTROPHE(') in the database and hence thrwing the error.

    and throwing this error::
    Microsoft OLE DB Provider for SQL Server error '80040e14'

    Line 1: Incorrect syntax near 'Story'.

    The control is a HTML control like this:
    <textarea name="txtstory" cols="100" rows="10" id="textfield3" ><%=rsEditStory .fields("story" )%></textarea>

    Please let me know what can be the errors??

    Thanks & Regards
  • DrBunchman
    Recognized Expert Contributor
    • Jan 2008
    • 979

    #2
    Hi Nitindel,

    Your problem is that SQL Server uses apostrophe's as string delimiters (they mark the beginning and end of strings). If you want to include apostrophe's in the data you insert in a database you must use a double apostrophe. Do a replace on your input string before you run your insert statement like so:

    sInput = Replace(sInput, "'", "''")

    This should fix your problem.

    Hope this helps,

    Dr B

    Comment

    • nitindel
      New Member
      • Dec 2007
      • 67

      #3
      Originally posted by DrBunchman
      Hi Nitindel,

      Your problem is that SQL Server uses apostrophe's as string delimiters (they mark the beginning and end of strings). If you want to include apostrophe's in the data you insert in a database you must use a double apostrophe. Do a replace on your input string before you run your insert statement like so:

      sInput = Replace(sInput, "'", "''")

      This should fix your problem.

      Hope this helps,

      Dr B

      Thanks a Lot...!!!!!


      It worked..!!!

      Comment

      Working...