How do I resolve the problem of passing a string that has quotes
within in a SQL statement? Sometimes the string contains a single
quote (') and some others it contains the double quote (")?
Any clue...
Thank you,
Stefania 3 3172
Depends on how you're delimiting the string in your SQL statement.
If you're using a single quote to delimit, you need to change all
occurrences of single quotes in the string to two single quotes in a row:
"... WHERE MyName = '" & Replace(strValu e, "'", "''") & "'"
Exagerated for clarity:
"... WHERE MyName = ' " & Replace(strValu e, " ' ", " ' ' ") & " ' "
On the other hand, if you're using a double quote to delimit, you need to
change all occurrences of double quotes to two double quotes in a row:
"... WHERE MyName = " & Chr$(34) & Replace(strValu e, Chr$(34), Chr$(34) &
Chr$(34)) & Chr$(34)
(In case you weren't aware, Chr$(34) is the same as ")
--
Doug Steele, Microsoft Access MVP http://I.Am/DougSteele
(no e-mails, please!)
"Stefania Scott" <st******@u.ari zona.edu> wrote in message
news:3e******** *************** ***@posting.goo gle.com... How do I resolve the problem of passing a string that has quotes within in a SQL statement? Sometimes the string contains a single quote (') and some others it contains the double quote (")?
Any clue...
Thank you,
Stefania
Doug,
Thank you for your reply.
My problem is that I cannot change the quotes within the string because
they have a meaning. Infact the string is the translation of a number to
be transformed in a barcode (code 128). So, maybe the solution is that I
need to search the string and if the string contains a double quote use
the single quote and viceversa. However, the problem rise if the string
contains both quotes and in this case I am lost.
Thanks again,
stefania
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
If you double your single quotes in your SQL statement, it in fact insert
only one single quote in the DB. The doubled single quote only means "don't
stop the string here and replace these doubled single quotes by only one
before processing the SQL statement" instead of "double this single quote
and insert them in order to my data to be correct". Not sure I'm very clear!
When retreiving your data, there will be only one single quote in it. HTH.
Yannick
"stefania" <st******@italy .it> wrote in message
news:40******** *************** @news.usenetmon ster.com... Doug, Thank you for your reply. My problem is that I cannot change the quotes within the string because they have a meaning. Infact the string is the translation of a number to be transformed in a barcode (code 128). So, maybe the solution is that I need to search the string and if the string contains a double quote use the single quote and viceversa. However, the problem rise if the string contains both quotes and in this case I am lost.
Thanks again,
stefania
*** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it! This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Bengt Richter |
last post by:
Why wouldn't quote-stuffing solve the problem, and let you treat \ as
an ordinary character? In a raw string, it's no good for preventing
end-of-quoting anyway, unless you want the literal \ in front of the quote
you are escaping.
Quote-stuffing is a variation on the old quote-doubling, extended to
deal with triple quotes as well (which makes it a little like HDLC bit stuffing).
IOW, treat \ as an ordinary character, and then if you...
|
by: PaulThomas |
last post by:
I want to "look" through a comma delimited String and "take it apart" by
finding the comma's and then put each "set of characters" into seperate
strings - - - maybe an array, maybe seperate cells in a table -or-
whatever... Can anyone help me locate the commands (samples) that might do
this?
Actually, I want to read a file and use these comma seperated groups of data
to "load" a database and this comma seperated data is the individual...
|
by: Ann Marinas |
last post by:
Happy New Year to all! :D
I am currently developoing an application that imports data from a CSV file.
Each comma represents an array item that I need to extract data with.
My problem is this...
I am encountering a string that has the example below:
a, b, c. "d,e,f,g", abcdef
|
by: Senthil |
last post by:
Code
----------------------
string Line = "\"A\",\"B\",\"C\",\"D\"";
string Line2 = Line.Replace("\",\"","\"\",\"\"");
string CSVColumns = Line2.Split("\",\"".ToCharArray());
|
by: Jeff S |
last post by:
In a VB.NET code behind module, I build a string for a link that points to a
JavaScript function. The two lines of code below show what is relevant.
PopupLink = "javascript:PopUpWindow(" & Chr(34) & PopUpWindowTitle & Chr(34)
& ", " & Chr(34) & CurrentEventDetails & ")"
strTemp += "<BR><A HREF='#' onClick='" & PopupLink & "'>" & EventName &
"</A><BR>"
The problem I have is that when the string variables or
contain a string with an...
| |
by: Mark Rae |
last post by:
Hi folks,
Apologies - am having a bit of a "senior moment"...
Is there a way to convert a string containing escaped characters into a
verbatim string literal?
I.e. converting something like
"This string contains \"double quotes\" and \'single quotes\'"
|
by: Charles Law |
last post by:
I have a string similar to the following:
" MyString 40 "Hello world" all "
It contains white space that may be spaces or tabs, or a combination, and I
want to produce an array with the following elements
arr(0) = "MyString"
arr(1) = 40
arr(2) = "Hello world"
|
by: vighnesh |
last post by:
Hello EveryOne
In my project I have to parse a string in Quotes as without Quotes.I tried
the following code but it didn't work to me.
I again getting the string with Quotes, Can Anybody suggest me where I went
wrong?
Thanks in advance.
code:
|
by: a |
last post by:
I need to write a regular expression to match a quoted string in which the
double quote character itself is represented by 2 double quotes. For
example:
"beginning ""nested quoted string"" end"
Any idea how to write this in boost::xpressive or boost::regex.
Thanks,
|
by: Michael Yanowitz |
last post by:
Hello:
If I have a long string (such as a Python file).
I search for a sub-string in that string and find it.
Is there a way to determine if that found sub-string is
inside single-quotes or double-quotes or not inside any quotes?
If so how?
Thanks in advance:
Michael Yanowitz
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |