Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    tib
    tib is offline
    New Coder
    Join Date
    Apr 2005
    Posts
    35
    Thanks
    0
    Thanked 0 Times in 0 Posts

    updating filed with ' in it

    Hi I have a field that may have a ' in it and seeing as though it is a text field in the update statement that I am building i have

    update table set field = ' " & str & " ' "

    if the str variable has a ' in it the it returns an error, how can i get around this, thanks for any input

  • #2
    Senior Coder nikkiH's Avatar
    Join Date
    Jun 2005
    Location
    Near Chicago, IL, USA
    Posts
    1,973
    Thanks
    1
    Thanked 32 Times in 31 Posts
    Did you mean to put this in the Classic ASP forum?

    If this post contains any code, I may or may not have tested it. It's probably just example code, so no getting knickers in a bunch over a typo, OK? If it doesn't have basic error checking in it, such as object detection or checking if objects are null before using them, put that in there. I'm giving examples, not typing up your whole app for you. You run code at your own risk.
    Bored? Visit
    http://www.kaelisspace.com/

  • #3
    New Coder
    Join Date
    Aug 2005
    Posts
    25
    Thanks
    0
    Thanked 0 Times in 0 Posts
    If you're using ASP.NET and using its built in web controls and use CommandParameters with the SqlCommand class, this is a total non-issue.
    Robert
    Gee! Web Tools
    Web Content Management / Internet Marketing modules including:
    Page Editor - Calendar Manager - News Editor - Contact Organizer - Mail Wizard

  • #4
    tib
    tib is offline
    New Coder
    Join Date
    Apr 2005
    Posts
    35
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I am using a datagrid with the oneditcommand and onupdatecommand, it was giving me an error where there was a ', so what i did was i replaced the ' with '' (2 single quotes) and then the sql stmt ran fin bc asp.net treats '' as a single quote in a string surrounded by double quotes. Just thought I'd share that incase anyone else is having that trouble


  •  

    Posting Permissions

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