#1
  1. No Profile Picture
    Registered User
    ASP Explorer (0 - 99 posts)

    Join Date
    Aug 2012
    Posts
    8
    Rep Power
    0

    Problem with ASP SQL single quote when insert or select


    we are facing issue with inserting or selecting records when user enter anything with ' (single quote) in text field. We dio not want to replace this. we need to enter this as single quote ' in oour dabtase. when user use this then our query getting break. what can be the solution
    for example if use enter " This is Gaurav's Farm" then break coz of single quote
  2. #2
  3. No Profile Picture
    Contributing User
    ASP Discoverer (100 - 499 posts)

    Join Date
    May 2009
    Location
    Somerset, UK
    Posts
    135
    Rep Power
    92
    I believe you must remove/replace it. You could use something similar such as a ` and then you could swap it back at the database end.
    Regards

    JD

    Software-Matters
  4. #3
  5. Contributing User
    ASP Skiller (1500 - 1999 posts)

    Join Date
    Mar 2005
    Location
    Columbus, OH
    Posts
    1,594
    Rep Power
    278
    use recordset and you do not need to replace anything below example schema how to do that
    Code:
    sql="select * from yourTable where 1=0"
    set cn=server.createObject("adodb.connection")
    constr=""  ' your connection string
    cn.open constr
    set rs=server.createobject("adodb.recordset")
    rs.open sql, cn, 1, 3 ' keyset lock optimistic
    rs.addNew
    rs("field1")="kjhkjhkj'kjh'"
    rs.update
    rs.close
    cn.close
    set rs=nothing
    set cn=nothing
    GK
    __________________________________________________ _____
    if you found this post is useful click Give Rep button (bottom side on this reply ) and agree

Similar Threads

  1. Problem with ASP SQL single quote when insert or select
    By gauravjain1 in forum Microsoft SQL Server
    Replies: 0
    Last Post: February 16th, 2013, 01:30 AM
  2. Simple Insert Command with Single Quote
    By ryanlcs in forum ASP Development
    Replies: 1
    Last Post: February 22nd, 2007, 03:49 AM
  3. is there any way i can insert single quote into database?
    By Steve Schofield in forum ASP Development
    Replies: 1
    Last Post: June 4th, 2001, 11:41 PM
  4. ? to insert values with ' (single quote)
    By Steve Schofield in forum SQL Development
    Replies: 1
    Last Post: June 9th, 2000, 03:49 PM
  5. Replies: 1
    Last Post: April 10th, 2000, 01:53 AM

IMN logo majestic logo threadwatch logo seochat tools logo