For Programmers: Free Programming Magazines  


Home > Archive > Visual Basic > April 2006 > How to ignore " in a string









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author How to ignore " in a string
Ian Davies

2006-04-27, 6:56 pm

I have the following sql string to run as a command in my VB6 project

strSQL = "LOAD DATA INFILE " & ImportFile & " INTO TABLE tPupils FIELDS
TERMINATED BY ',' ENCLOSED BY ' " ' LINES TERMINATED BY '\n';"

Problem is the double quote at position ......" ' LINES......
the command to fail thinking the double quote is ending the SQL but it is
infact just indicating that the file being read in has fields enclosed by "
How do I rewrite this string so I can use the double quote in it as part of
the string and not to terminate it

Thanks
ps the sql is to update a mysql table


Bob Butler

2006-04-27, 6:56 pm

"Ian Davies" <iandan.dav@virgin.net> wrote in message
news:tq84g.3527$ZB4.3406@newsfe7-win.ntli.net
> I have the following sql string to run as a command in my VB6 project
>
> strSQL = "LOAD DATA INFILE " & ImportFile & " INTO TABLE tPupils
> FIELDS TERMINATED BY ',' ENCLOSED BY ' " ' LINES TERMINATED BY '\n';"



....ENCLOSED BY ' "" ' LINES ...

or

....ENCLOSED BY ' " & Chr$(34) & " ' LINES ...

--
Reply to the group so all can participate
VB.Net: "Fool me once..."

Ian Davies

2006-04-27, 6:56 pm

Thanks
That solved that problem
Still not working though. Error message indicating a syntax error. I think
it is something to do with a variation thats needed somewhere due to the use
of mysql.
Will post again if I cant resolve it.
Thanks again
Ian

"Bob Butler" <tiredofit@nospam.ever> wrote in message
news:O8LhyyiaGHA.996@TK2MSFTNGP04.phx.gbl...
> "Ian Davies" <iandan.dav@virgin.net> wrote in message
> news:tq84g.3527$ZB4.3406@newsfe7-win.ntli.net
>
>
> ...ENCLOSED BY ' "" ' LINES ...
>
> or
>
> ...ENCLOSED BY ' " & Chr$(34) & " ' LINES ...
>
> --
> Reply to the group so all can participate
> VB.Net: "Fool me once..."
>



Jim Carlock

2006-04-27, 6:56 pm

"Ian Davies" <iandan.dav@virgin.net> wrote:
> That solved that problem
> Still not working though. Error message indicating a
> syntax error. I think it is something to do with a variation
> thats needed somewhere due to the use of mysql.
> Will post again if I cant resolve it.


Try removing the spaces around the apostrophe?

Public Const vbQM As String = """"

sSQL = "LOAD DATA INFILE " & vbQM & ImportFile & _
vbQM & " INTO TABLE tPupils FIELDS TERMINATED " &
"BY ',' ENCLOSED BY '" & vbQM & "' LINES " & _
"TERMINATED BY '\n';"

Jim Carlock
Post replies to the group.
--
Swimming Pool Builders http://www.aquaticcreationsnc.com/


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com