Re: Wrong sintax...? GOT IT!

From: Frank Hickman (fhickman_nosp_at_m_noblesoft.com)
Date: 02/23/04


Date: Sun, 22 Feb 2004 20:05:48 -0500

Oh yeah, I forgot your using VBScript.

--
Frank
"damned" <damned@iol.pt> wrote in message
news:OH7JtgZ%23DHA.4088@tk2msftngp13.phx.gbl...
> Frank,
>
> I was already trying the function Replace(strData4Field1, "'", "''")
> (VBScript).
> But it looks like it's Replace(strData4Field1, "'", "'''")!!!
>
> Ok, now, and thanks to you (not MS help), it's working.
>
> Thank you all,
> damned
>
> "Frank Hickman" <fhickman_nosp@m_noblesoft.com> wrote in message
> news:pdqdnQ_x1Zg-vqTdRVn-tA@comcast.com...
> > You can keep the embedded quotes but you must use the SQL method for
> > representing them...
> >
> > Say you have the string "That's how the cookie crumbles."  To insert
this
> > string into the field you would have to make the string
contain."That'''s
> > how the cookie crumbles."  So you would need to write a function that
adds
> > this or you, something like this...
> >
> > CString& FixQuotes( CString& strInput )
> > {
> >     CString strIn( strInput );
> >     int nNdx= 0;
> >     for( int nPos= 0; nPos < strIn.GetLength(): nPos++ )
> >     {
> >         strInput[nNdx]= strIn[nPos];
> >         if ( strIn[nPos] == _T('\'') )
> >         {
> >             strInput += _T("''");
> >             nNdx += 2;
> >         }
> >         else
> >         {
> >             ++nNdx;
> >         }
> >     }
> >     return strInput;
> > }
> >
> > CString strVal= _T("That's how the cookie crumbles.");
> > strVal= FixQuotes( strVal );
> >
> > strVal should now contain: That'''s how the cookie crumbles.
> >
> > This is off the top of my head so you may need to tweak it.
> >
> > HTH
> > --
> > ============
> > Frank Hickman
> > NobleSoft, Inc.
> > ============
> > Replace the _nosp@m_ with @ to reply.
> >
> >
> > "damned" <damned@iol.pt> wrote in message
> > news:uEXeKsY%23DHA.2592@TK2MSFTNGP10.phx.gbl...
> > > eheheh (dumb damned)
> > >
> > > Now this leads me to another problem...
> > > I need to insert the quotes also!
> > >
> > > Must I first parse the quotes, then insert the data and then, finaly,
> > parse
> > > the quotes back again? Or is there a better way to accomplish this?
> > >
> > > Regards,
> > > damned
> > >
> > > "Frank Hickman" <fhickman_nosp@m_noblesoft.com> wrote in message
> > > news:7Zednbl_lrEGE6vdRVn-hw@comcast.com...
> > > > Glad you got it!  Yep, embedded quotes will get ya just about
> everytime
> > :)
> > > >
> > > > --
> > > > Frank
> > > >
> > > >
> > > > "damned" <damned@iol.pt> wrote in message
> > > > news:eO%23GWJA%23DHA.3648@TK2MSFTNGP11.phx.gbl...
> > > > > Frank,
> > > > >
> > > > > The tags were only for marking script block (wrong choice).
> > > > >
> > > > > I've found the problem!
> > > > > Some of the field data contains the "'" character. So the
> > concatenation
> > > of
> > > > > "INSERT INTO MyTable (Field1) VALUES ('" & strVar & "')" results
in
> > > error!
> > > > > (''/ab/'').
> > > > > I must strip all data before insering.
> > > > >
> > > > > My first code example missled you. I gave an hardcoded example.
> Sorry.
> > > > >
> > > > > Regards,
> > > > > damned
> > > > >
> > > > > "Frank Hickman" <fhickman_nosp@m_noblesoft.com> wrote in message
> > > > > news:4qqdnbSBQtoi-6vdRVn-hw@comcast.com...
> > > > > > Yes they did :)  Are they part of your script or did you just
use
> > them
> > > > to
> > > > > > show the start and end of your code?  Or is your script in an
html
> > > file
> > > > > that
> > > > > > you want to use ASP in?
> > > > > >
> > > > > > Here is my adotest.vbs script which also works...
> > > > > >
> > > > > > ****** Start ******
> > > > > >
> > > > > > Option Explicit
> > > > > >
> > > > > > Dim conDB
> > > > > > Set conDB = CreateObject("ADODB.Connection")
> > > > > > With conDB
> > > > > >     .Open "DSN=MyDatabase"
> > > > > >     .Execute "INSERT INTO MyTable (Field1) VALUES ('\ab\')"
> > > > > >     .Close
> > > > > > End With
> > > > > > Set conDB = Nothing
> > > > > >
> > > > > >
> > > > > > ****** End ******
> > > > > >
> > > > > > --
> > > > > > Frank
> > > > > >
> > > > > > "damned" <damned@iol.pt> wrote in message
> > > > > > news:ufZd3d%239DHA.1428@TK2MSFTNGP12.phx.gbl...
> > > > > > > Frank,
> > > > > > >
> > > > > > > It's a .vbs administrative script.
> > > > > > > Maybe using the "<%"/"%>" tags confused you.
> > > > > > >
> > > > > > > Regards,
> > > > > > > damned
> > > > > > >
> > > > > > > "Frank Hickman" <fhickman_nosp@m_noblesoft.com> wrote in
message
> > > > > > > news:lMWdnVHj-Lj8SajdRVn-tA@comcast.com...
> > > > > > > > Okay that confused me.  How are you executing the script?
In
> IE
> > > or
> > > > do
> > > > > > you
> > > > > > > > have a command line asp processor?
> > > > > > > >
> > > > > > > > "damned" <damned@iol.pt> wrote in message
> > > > > > > > news:e6x0YG59DHA.4064@TK2MSFTNGP09.phx.gbl...
> > > > > > > > > Frank,
> > > > > > > > >
> > > > > > > > > Thank you for your interest and testing work.
> > > > > > > > >
> > > > > > > > > I don't have IUSR_ & IWAM_ accounts on the PC running the
> > > script.
> > > > No
> > > > > > IIS
> > > > > > > > is
> > > > > > > > > installed there. It's an administrativ
> > > > > > Conript.
> > > > > > > > >
> > > > > > > > > Regards,
> > > > > > > > > damned
> > > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > > >
> > > > > >
> > > > > >
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >
> >
> >
>
>


Relevant Pages

  • Re: Non-printing ASCII characters in WinXP Home, Admin Password - cant do it?
    ... Hi Frank, ... When giving the account a password, ... > (without the quotes), and then I held down the Alt key on the ... > non-printing character in it for a Limited Account on WinXP Home ...
    (microsoft.public.windowsxp.security_admin)
  • Re: Integrative Medizin
    ... Im Übrigen weise ich gelegentlich per Quotes auf diejenigen ... Gruß, Frank ... Prev by Date: ... Next by Date: ...
    (de.sci.medizin.misc)
  • Re: What is an "Individual Right"?
    ... Ghost) wrote: ... quotes you cut & paste from websites that provide old fake gun ... FAKE by citing the quotes in full context with FULL CITATIONS. ... If you can't do that Frank, and we know you can't, then you ...
    (talk.politics.guns)
  • Re: Wrong sintax...? GOT IT!
    ... will escape anything that needs to be escaped for you. ... > CString strIn(strInput); ... >> I need to insert the quotes also! ... >> Must I first parse the quotes, then insert the data and then, finaly, ...
    (microsoft.public.data.ado)
  • Re: Wrong sintax...? GOT IT!
    ... > CString strIn(strInput); ... That'''s how the cookie crumbles. ... >> I need to insert the quotes also! ... >> Must I first parse the quotes, then insert the data and then, finaly, ...
    (microsoft.public.data.ado)