parsing single quotes when using an Access databas

Results 1 to 2 of 2

Thread: parsing single quotes when using an Access databas

  1. #1
    Join Date
    Dec 1969

    Default parsing single quotes when using an Access databas

    wondered if anyone could possibly help with this.<BR><BR>In one of my current projects there is alot of user input via forms which is stored in an access database, the problem is parsing the quotes in any input, since text and memo fields do not like single quotes in access.<BR><BR>What I am doing is constructing the SQL query and putting it into a variable, and then trying to use a regular expression to replace all single quotes with two single quotes to solve the problem.<BR><BR>This is however made complicated by the fact that when passing text and memo data to the access database you have to enclose the input in single quotes also, so to sum up the regular expression, I need to find all single quotes in a string which is enclosed in single quotes (which need to stay) inside the SQL query string.<BR><BR>can anyone help with this expression?<BR><BR>thx

  2. #2
    Join Date
    Dec 1969

    Default RE: parsing single quotes when using an Access dat

    The easiest way to replace some simple string with another is to ditch regexps and just use VBScript&#039;s Replace method. I am assuming you have a number of variables that correspond to the user&#039;s input, and then you are building up a dynamic SQL string based on these values? So let&#039;s say you have:<BR><BR>Dim name<BR>name = Request.Forms("name")<BR><BR>Dim description<BR>description = Request.Forms("description")<BR><BR>Now you want to build your SQL string, but before you do, you need to replace all single parenthesis with two of &#039;em for the variables name and description, like so:<BR><BR>name = Replace(name, "&#039;", "&#039;&#039;")<BR>description = Replace(description, "&#039;", "&#039;&#039;")<BR><BR>Now you can build your dynamic SQL string and everyone will be hunky dorey.

Posting Permissions

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