How can I get through the "'"

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ivan V via DotNetMonster.com

    #1

    How can I get through the "'"

    Dear All:

    I got a problem a savinf problem about my data into sql server. If the
    remarks filed include the "'" such as Chan's, Int'L, an error message will
    pop up whixh is caused by the "'", anyone knows I can get this through???
    Thanks!


    --
    Message posted via DotNetMonster.c om
    Best online pokies for real money in Australia and learn about safety and game mechanics in this comprehensive guide.

  • Cor Ligthert [MVP]

    #2
    Re: How can I get through the "'&quot ;

    Ivan,

    I assume that you are not typing it directly into the SQL server, therefore
    how do you do it.

    In other words, what classes are you using, how does your insertstring look
    like.

    Cor


    Comment

    • Ivan V via DotNetMonster.com

      #3
      Re: How can I get through the "'&quot ;

      Hi Cor, thanks for that reply, in my case, for instance, in a taxt box, there
      is a name "INT'L" in it and i am using sql command "insert into" and that's
      where my problem appeared!

      Ivan


      --
      Message posted via http://www.dotnetmonster.com

      Comment

      • Cor Ligthert [MVP]

        #4
        Re: How can I get through the "'&quot ;

        Ivan,

        Therefore are the parameters.
        See this sample on our website.


        It is with the Fill however I assume that you can translate it to an update.
        An even simpler sample is on the site with SQL.

        (The datetime is used because that is mostly the most awfull one if you are
        not living in the USA)

        I hope this helps,

        Cor


        Comment

        • Ivan V via DotNetMonster.com

          #5
          Re: How can I get through the "'&quot ;

          Hi Cor, seems that's the not sample that I am looking for. By the way, thanks
          a lot!


          --
          Message posted via http://www.dotnetmonster.com

          Comment

          • Oenone

            #6
            Re: How can I get through the "'&quot ;

            Ivan V via DotNetMonster.c om wrote:[color=blue]
            > I got a problem a savinf problem about my data into sql server.
            > If the remarks filed include the "'" such as Chan's, Int'L, an error
            > message will pop up whixh is caused by the "'", anyone knows I can
            > get this through???[/color]

            Replace each single-quote character with two single-quote characters in your
            string, e.g.:

            \\\
            sql = "INSERT INTO YourTable "
            sql &= "VALUES ('" & Replace(YourVal ue, "'", "''") & "')"
            ///

            When SQL Server sees two single-quotes within a quoted string, it will
            interpret them as a single single-quote within the value.

            Hope that makes sense. :-)

            --

            (O) e n o n e


            Comment

            • Ivan V via DotNetMonster.com

              #7
              Re: How can I get through the "'&quot ;

              Thanks Oenone, it works well for me now. :-)


              --
              Message posted via http://www.dotnetmonster.com

              Comment

              Working...