1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

How to Insert quotes into DB

Discussion in 'C#' started by jonyroufe, Nov 1, 2009.

  1. #1
    hi, i'm trying to insert quotes into sql database, i get an exception because it's a part of the sql query..
    can anyone help me?

    thank's

    jony
     
    jonyroufe, Nov 1, 2009 IP
  2. Nytrolix

    Nytrolix Peon

    Messages:
    24
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    rs.open "SELECT * FROM whereever", myconn, 3, 3
    rs("textfield") = server.htmlencode(textstring)
    rs.update
    rs.close
     
    Nytrolix, Nov 3, 2009 IP
  3. yugolancer

    yugolancer Well-Known Member

    Messages:
    320
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    110
    #3
    Use replace function !!!

    e.g.
    
    Dim fixedstring as String = "yugolancer's reply sux"
    fixedstring = fixedstring.Replace("'", "''")
    Dim sql As String = "INSERT INTO table (column1) VALUES ('" & fixedstring & "')"
    etc.
    
    Code (markup):
     
    yugolancer, Nov 5, 2009 IP
  4. vihutuo

    vihutuo Well-Known Member

    Messages:
    1,511
    Likes Received:
    34
    Best Answers:
    0
    Trophy Points:
    180
    #4
    Use parameters
     
    vihutuo, Nov 14, 2009 IP
  5. makeitlive

    makeitlive Peon

    Messages:
    10
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    parameters is the best way to go
     
    makeitlive, Dec 21, 2009 IP
  6. alexpr07

    alexpr07 Active Member

    Messages:
    284
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    73
    #6
    You can use replace function to change quotes to html code, for example
    string=replace(string, chr(34), """, 1, -1, 1)
    Code (markup):
     
    alexpr07, Dec 23, 2009 IP
  7. bertasoft

    bertasoft Peon

    Messages:
    11
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    There isn't parameters in classic asp...
     
    bertasoft, Jan 8, 2010 IP
  8. awhgemma

    awhgemma Peon

    Messages:
    18
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Always use parameters when inserting / updating etc ... its also the best way to stop SQL injection
     
    awhgemma, Jan 18, 2010 IP
  9. Where2Buy.eu

    Where2Buy.eu Peon

    Messages:
    17
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #9
    I am sure All the above answers would work, but what is the exact function that you require
    More info about your SQL server and language used can help???
     
    Where2Buy.eu, Jan 20, 2010 IP