Re: mdb access to names containing "'"

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Kevin Spencer (kspencer_at_takempis.com)
Date: 07/23/04


Date: Fri, 23 Jul 2004 15:10:55 -0400

sqltemp = "select * from logindata where lastname = '" & Replace(myname,
"'", "''") & "'"

-- 
HTH,
Kevin Spencer
.Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
"G.F.Schl" <anonymous@discussions.microsoft.com> wrote in message
news:307101c470e4$073c1910$a301280a@phx.gbl...
> Maybe I misunderstand but I can't make this work:
> 1. (using three ")
> sqltemp="select * from logindata where lastname=""" &
> myname & """"
> yields the following error:
> Microsoft OLE DB Provider for ODBC Drivers
> error '80040e10'
> [Microsoft][ODBC Microsoft Access Driver] Too few
> parameters. Expected 1.
>
> 2. (using two ' and one ")
> sqltemp="select * from logindata where lastname=''" &
> myname & "''"
> yields the following error:
> Microsoft OLE DB Provider for ODBC Drivers
> error '80040e14'
> [Microsoft][ODBC Microsoft Access Driver] Syntax error
> (missing operator) in query
> expression 'lastname=''Testing'''.
>
> 3. (using two ')
> sqltemp="select * from logindata where lastname='' &
> myname & ''"
> yields the following error:
> Microsoft OLE DB Provider for ODBC Drivers
> error '80040e10'
> [Microsoft][ODBC Microsoft Access Driver] Too few
> parameters. Expected 1.
>
> 4. (using one ' and one ")
> sqltemp="select * from logindata where lastname='" &
> myname & "' "
> works fine unless myname contains ' than error:
> Microsoft OLE DB Provider for ODBC Drivers
> error '80040e14'
> [Microsoft][ODBC Microsoft Access Driver] Syntax error
> (missing operator) in query
> expression 'lastname='O'Test''.
>
>
> >-----Original Message-----
> >Replace(myname, "'", "''") ' Replaces single quotes with
> doubled single
> >quotes in the value
> >
> >-- 
> >HTH,
> >Kevin Spencer
> >..Net Developer
> >Microsoft MVP
> >Big things are made up
> >of lots of little things.
> >
> >"G.F.Schl" <anonymous@discussions.microsoft.com> wrote in
> message
> >news:2c1c01c470c0$8117f840$a401280a@phx.gbl...
> >> The following statement works unless "myname" contains
> >> a '.
> >> sqltemp="select * from logindata where lastname='" &
> >> myname & "' "
> >>
> >> I tried using your suggestion but get only exec errors.
> >> How do you suggest to code?
> >> >-----Original Message-----
> >> >Double your single quotes in the string.
> >> >
> >> >-- 
> >> >HTH,
> >> >Kevin Spencer
> >> >..Net Developer
> >> >Microsoft MVP
> >> >Big things are made up
> >> >of lots of little things.
> >> >
> >> >"G.F.Schl" <anonymous@discussions.microsoft.com> wrote
> in
> >> message
> >> >news:280e01c47079$566415d0$a601280a@phx.gbl...
> >> >> In an ASP I access an Access DB containing names. I
> >> tried
> >> >> everthing I can imagine to use """ instead of '"
> >> including
> >> >> defining a constant (X37) but it either fails with an
> >> exec
> >> >> error or fails when names containing ' are processed.
> >> >> MY current code is:
> >> >> sqltemp="select * from logindata where lastname='"
> >> >> sqltemp=sqltemp & myname & "'"
> >> >> (It doesn't work when I try to make it with one
> >> statement)
> >> >> I am using FP2002.
> >> >> Can anyone tell me how to code this for handling
> names
> >> >> that contain '.
> >> >> Thanks 10to6
> >> >
> >> >
> >> >.
> >> >
> >
> >
> >.
> >


Relevant Pages

  • Re: Change default return string
    ... If you just want a field that is True/False to display Yes/No ... [Microsoft][ODBC Microsoft Access Driver] Too few parameters. ...
    (microsoft.public.frontpage.programming)
  • Re: UserAgent data
    ... Microsoft Regional Director ... "Kevin Spencer" wrote in message ... >> John Timney ... >> Microsoft MVP ...
    (microsoft.public.dotnet.framework.aspnet)
  • RE: Missig global.asa
    ... Technical Information (for support personnel) ... Error Type: ... Microsoft OLE DB Provider for ODBC Drivers ... [ODBC Microsoft Access Driver] ...
    (microsoft.public.inetserver.iis)
  • Re: help,i cant create database!!!
    ... > Technical Information (for support personnel) ... > Error Type: ... > [Microsoft][ODBC Microsoft Access Driver] The Microsoft ...
    (microsoft.public.inetserver.iis)
  • help,i cant create database!!!
    ... Error Type: ... Microsoft OLE DB Provider for ODBC Drivers ... [ODBC Microsoft Access Driver] ... Jet database engine cannot open the file ''. ...
    (microsoft.public.inetserver.iis)