Notices

Great community. Great ideas.

Welcome to ASP/Free, a community dedicated to helping beginners and professionals alike in improving their knowledge of Microsoft's development and administration technologies. Sign up today to gain access to the combined insight of tens of thousands of members.

Thread: Problem with ASP SQL single quote when insert or select

Results 1 to 3 of 3
Share This Thread →
  1. #1
    gauravjain1 is offline Registered User
    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
    SoftwareMatters is offline Contributing User
    Join Date
    May 2009
    Location
    Somerset, UK
    Posts
    131
    Rep Power
    91
    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 - Bespoke Access Database Design and Development

  3. #3
    gk53's Avatar
    gk53 is offline Contributing User
    Join Date
    Mar 2005
    Location
    Columbus, OH
    Posts
    1,535
    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

Share This Thread →

Become Part of This Conversation

Join NowFor Free!

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

ASP Free Advertisers and Affiliates