Sql Quotation Marks in Strings

Results 1 to 5 of 5

Thread: Sql Quotation Marks in Strings

  1. #1
    Newbie2 Guest

    Default Sql Quotation Marks in Strings

    i cant get this query to run in asp....<BR><BR>rsTemp.Open "Select * from temp Where text = """ & Request.Form("txtText") & """", dbConn,adOpenDynamic,adCmdTable<BR><BR>yields this string <BR><BR>Select * from GisDb Where GisDbDesc = "joel&#039s new db"<BR>which works great in Access<BR><BR>but gives me this nasty error in asp...<BR>Too few parameters. Expected 1.

  2. #2
    Richard L. Guest

    Default RE: Sql Quotation Marks in Strings

    I haven&#039t had a chance to try it.. but give either of these a go:<BR><BR>rsTemp.Open "Select * from temp Where text = " & "" & Request.Form("txtText") & "", dbConn,adOpenDynamic,adCmdTable<BR><BR>rsTemp.Open "Select * from temp Where text = &#039" & Request.Form("txtText") & "&#039" , dbConn,adOpenDynamic,adCmdTable

  3. #3
    Join Date
    Dec 1969
    Posts
    463

    Default RE: Sql Quotation Marks in Strings

    What you need to do is replace the &#039 width &#039&#039.<BR>I have used the following many times and it works great.<BR><BR>strText=Request.Form("txtText") <BR>strText = Replace(strText, "&#039", "&#039&#039") <BR><BR>rsTemp.Open "Select * from temp Where text = &#039" & strText & "&#039"<BR><BR>Hope This Helps

  4. #4
    Join Date
    Dec 1969
    Posts
    463

    Default RE: Sql Quotation Marks in Strings

    My last message was hard to read once it was posted. What you are replacing is the single quote with two single quotes. My last message looks like a bunch of double quotes, but thats just the way it is being dispalyed.


  5. #5
    newbie2 Guest

    Default RE: Sql Quotation Marks in Strings

    Thanks a lot... its working much better now

Posting Permissions

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