Re: handling apostrophe

Tech-Archive recommends: Speed Up your PC by fixing your registry

From: Vishal Khajuria (VishalKhajuria_at_discussions.microsoft.com)
Date: 09/29/04


Date: Wed, 29 Sep 2004 04:49:12 -0700

Hi,
Try changing ur routine such that single quotes are replaced with double
quotes.
CustomerID = Replace(CustomerID, "'", "''")
I hope this wll work.
Regards
Vishal Khajuria
Sungard

"darkstar_E2" wrote:

> yes i believe so. but the real problem behind this scenario is not that i am
> coding in vb.net and i am using a routine that will get data from the
> database by feeding it with a sql statement as parameter.
> Let say: GetDataFromStatement("Select * from tblARInvoice")
> The problem here is if i will feed the parameter with a string variable that
> will determine tha filter.
> Let say I have a variable in Vb ( _CustomerID).. and i will use this to
> filter my data.
> i will use this :
> GetDataFromStatement("Select * from tblARInvoice where strCustomer = ' "
> & _CustomerID & "'" )
> Now, what if the _CustomerID variable contains boy's game..
> How can i feed it in the routine if i am only a user of that routine..
> I would really appreciate an answer...
>
>
>
>
>
>
>
> "Tibor Karaszi" <tibor_please.no.email_karaszi@hotmail.nomail.com> wrote in
> message news:OOJPH8gpEHA.3300@TK2MSFTNGP12.phx.gbl...
> > > But i do not want to use this:
> > > set @str = 'boy''s game'
> >
> > Why don't you want to use the proper way of doing it? Prefixing a single
> quote with another single
> > quote is the defined and documented way to get a single quote into the
> column/variable. It is even
> > defined in the ANSI/ISO SQL standard.
> >
> > --
> > Tibor Karaszi, SQL Server MVP
> > http://www.karaszi.com/sqlserver/default.asp
> > http://www.solidqualitylearning.com/
> >
> >
> > "darkstar_E2" <darwin_e@comtechsolutions.com> wrote in message
> > news:%23RngP4gpEHA.3300@TK2MSFTNGP12.phx.gbl...
> > > Dear All,
> > > I have some trouble handling the apostrophe( ' ) contained in a string.
> Let
> > > say i have a string (boy's game). How can i pass this to a variable @str
> ..
> > > I can't pass this using this:
> > > set @str = 'boy's game' -> this will produce error.
> > > But i do not want to use this:
> > > set @str = 'boy''s game'
> > > Please reply to this problem....
> > >
> > >
> >
> >
>
>
>



Relevant Pages

  • Re: Kernel Panic
    ... On Thu, 2004-02-05 at 19:52, Stuart Sears wrote: ... >> They're both just single quotes. ... >> Regards Roger ... I made the assumption that the sed needed a different type of quote mark ...
    (RedHat)
  • Re: BJC HLCB thread
    ... So I worked on Boxes and put a ... to learn something new and make you construct a routine from your ... what made it especially funny was that Andy Vass has been ...
    (rec.juggling)
  • Re: why tcl/tk doesn`t incorporate tclx, tile, etc.
    ... Why bash tries to expand backticks at this place, ... I'm using 3.00.0without your problem (backtick is taken literally). ... literal single quote between single quotes. ...
    (comp.lang.tcl)
  • Re: re-quoting (aka reconstituting a command line)
    ...     return cmdline; ... int extra_s, extra_d, quote, i; ... // embedded single quotes, use a hybrid strategy of examining ... main(int argc, char **argv) ...
    (comp.unix.shell)
  • Re: handling apostrophe
    ... but the real problem behind this scenario is not that i am ... database by feeding it with a sql statement as parameter. ... How can i feed it in the routine if i am only a user of that routine.. ... > quote is the defined and documented way to get a single quote into the ...
    (microsoft.public.sqlserver.programming)