still unsolved: apostrophy in data field

Results 1 to 2 of 2

Thread: still unsolved: apostrophy in data field

  1. #1
    Join Date
    Dec 1969

    Default still unsolved: apostrophy in data field

    This problem must have been solved 100 times, but I&#039m still stumped.<BR>My JScript ASP script has problems storing data into ACCESS<BR>when there are apostrophies in the data (ex. bob&#039s house ).<BR>I know that for SQL you can just replace a single quote with a pair of them, but my problem appears to be with JScript, BEFORE the SQL is executed.<BR>Problem is that using ADO with Access, your text fields need to be single quoted.<BR><BR>conn.Execute( "INSERT INTO mytable (fld1) VALUES (&#039" + val1 +"&#039)" ); <BR><BR>I can&#039t yet figure out what to do if val1 = "bob&#039s house"<BR><BR>In that case the sql string in the Execute statment is<BR>malformed.<BR><BR>can someone please point me to a Jscript solution???<BR>thanks in advance,<BR>-- david

  2. #2 Guest

    Default RE: still unsolved: apostrophy in data field

    I created a little function called SQL Sanitize that basically takes a passed string and replaces all occurrences of &#039 with &#039&#039. That&#039s all there is to it. In JavaScript, VBScript and JScript there is a method/function called Replace that will enable you to do this.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts