Re: handling apostrophe
From: Vishal Khajuria (VishalKhajuria_at_discussions.microsoft.com)
Date: 09/29/04
- Next message: Hugo Kornelis: "Re: Question on Locks"
- Previous message: Tudor Sofron: "Resetting DTS password"
- In reply to: darkstar_E2: "Re: handling apostrophe"
- Messages sorted by: [ date ] [ thread ]
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....
> > >
> > >
> >
> >
>
>
>
- Next message: Hugo Kornelis: "Re: Question on Locks"
- Previous message: Tudor Sofron: "Resetting DTS password"
- In reply to: darkstar_E2: "Re: handling apostrophe"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|