i need to escape characters, such as ( % and/or _ and/or [ ),
since i have database entries that have such characters in them.
the following piece works fine in an SQL statement (c#), but doesn't
return entries that have one of the above characters in the argument.
... like '%" + tbProduct.Text.Replace("'", "''") + "%' ...
thanks folks...
-¿- 3 22240
Hi,
Would doing a myString.Replace("X", "[X]") will work.
Joe
-- http://www.csharp-station.com
"forest demon" wrote:
i need to escape characters, such as ( % and/or _ and/or [ ),
since i have database entries that have such characters in them.
the following piece works fine in an SQL statement (c#), but doesn't
return entries that have one of the above characters in the argument.
... like '%" + tbProduct.Text.Replace("'", "''") + "%' ...
thanks folks...
-¿-
dude! that's what i was looking for.
i can stack them like so if need be:
'%" + tbProduct.Text.Replace("'", "''").Replace("%", "[%]")
..Replace("[", "[[]") + "%'
that works fine for me now...
thanks man....i appreciate your input!
Joe Mayo (C# MVP) wrote:
Hi,
Would doing a myString.Replace("X", "[X]") will work.
Joe
-- http://www.csharp-station.com
"forest demon" wrote:
i need to escape characters, such as ( % and/or _ and/or [ ),
since i have database entries that have such characters in them.
the following piece works fine in an SQL statement (c#), but doesn't
return entries that have one of the above characters in the argument.
... like '%" + tbProduct.Text.Replace("'", "''") + "%' ...
thanks folks...
-¿-
Hi!
It is a recommended practice to use @parameters to provide placeholders in
your Sql statements. Construct the Sql statement with parameters and assign
the values by mapping each value to the corresponding parameter. This has
the benefit of a much cleaner Sql statement and avoids potential code
injections.
Let me know if you need additional help on this.
--
With regards
Anders Borum / SphereWorks
Microsoft Certified Professional (.NET MCP) This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Paul Rubin |
last post by:
I frequently find myself writing stuff like
# compute frob function, x has to be nonnegative
x = read_input_data()
assert x >= 0, x # mis-use of "assert" statement
frob = sqrt(x)...
|
by: Wolfgang Jeltsch |
last post by:
Hello,
I want to write a list class with an iterator class as an inner class. The
iterator class must have access to certain private members of the list
class in order to do its job. Here is a...
|
by: CoolPint |
last post by:
I read in books that nested class cannot access private members of
nesting class and vice versa unless they are made friends. Somehow, my
compiler is letting my nested class member functions access...
|
by: John Harrison |
last post by:
Both gcc 3.3.1 and VC++ 7.1 compile the following code.
struct Outer
{
struct Inner
{
int f() { return c; }
};
private:
static const int c;
|
by: Ruby Tuesday |
last post by:
Hi, I was wondering if expert can give me some lite to convert my word table
into access database.
Note: within each cell of my word table(s), some has multi-line data in it.
In addition, there...
|
by: hk |
last post by:
Hello,
I would like to create a special version of hashtable,
either inherited from hastable or from DictionaryBase.
I would like to be able to access the class from outside
in the following...
|
by: tshad |
last post by:
I am trying to access my log files and am running into a permissions
problem.
I am doing the following:
******************************************************************
private void...
|
by: baroque Chou |
last post by:
anyone know how google spiders access web site, how dose they manage to
get the href information? do they have special access right or
something? any help is appreciated
|
by: MyRedz |
last post by:
i want to do a program that requires user to input float numbers,characters like this
printf("please enter the value with its SI unit...");
scanf(" %lf %c",&value,&si);
but then there is an...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
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...
|
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...
|
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...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |