SQL Question

Results 1 to 2 of 2

Thread: SQL Question

  1. #1
    Cade Guest

    Default SQL Question

    I am looking for a recordset that has the &#039; character, but this presents a problem becuase I use<BR><BR>strExample="Example&#039;"<BR>sql="SELE CT * FROM tblUsers where fldName=&#039;" & strExample & "&#039;"<BR><BR>This creats an error.<BR><BR>Thanks for any help

  2. #2
    bmasters Guest

    Default RE: SQL Question

    when you have a single quote in a string value you are passing in a select statement, you must change it to two single quotes. <BR><BR>try including this function on any page you interact with the db:<BR><BR>Function dbPrep(string)<BR> If Not string = "" Then<BR> dbPrep = "&#039;" & Trim(Replace(string, "&#039;", "&#039;&#039;")) & "&#039;"<BR> Else<BR> dbPrep = Null<BR> End If<BR>End Function<BR><BR>Now in your select statement, you simply write:<BR> sql = "SELECT * FROM tblUsers WHERE fldName = " & dbPrep(strExample)<BR><BR>You can also expand the function to include numerical values.<BR>

Posting Permissions

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