Hi,
I need to use single qoutation ( ' ) in my filter string but I get error
message. how can I do something like this:
mysearch = "Bob's book";
dataView.RowFilter = "myfield LIKE '" + mysearch + "%'";
even I changed "mysearch to this but still it's not working:
mysearch = "Bob\'s book";
thanks
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it! 8 8498
Newbie,
You need to use two single quotation marks in the "mysearch" variable:
Something like mysearch = "Bob''s book";
That's: B, o, b, single quote, single quote, s ...
Hope this helps
Jay
"newbie_csharp" <an*******@devdex.com> wrote in message
news:%2***************@tk2msftngp13.phx.gbl... Hi, I need to use single qoutation ( ' ) in my filter string but I get error message. how can I do something like this:
mysearch = "Bob's book"; dataView.RowFilter = "myfield LIKE '" + mysearch + "%'";
even I changed "mysearch to this but still it's not working:
mysearch = "Bob\'s book";
thanks *** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it!
newbie_csharp,
I believe you will have to double up on the quotes, like this:
// Alter the string so that it can be included in the filter.
filterString = mysearch.Replace(@"'", @"''");
An then search on that.
I personally don't like this, and have suggested a number of times to
people at MS that they provide something like parameters for this kind of
operation (so that we could pass CLR types and not have to worry about
conversions like this).
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"newbie_csharp" <an*******@devdex.com> wrote in message
news:%2***************@tk2msftngp13.phx.gbl... Hi, I need to use single qoutation ( ' ) in my filter string but I get error message. how can I do something like this:
mysearch = "Bob's book"; dataView.RowFilter = "myfield LIKE '" + mysearch + "%'";
even I changed "mysearch to this but still it's not working:
mysearch = "Bob\'s book";
thanks *** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it!
Nicholas,
Parameters or even simply an Encode/Escape function (like Regex.Escape &
Regex.Unescape) that properly encodes the string so it works correctly as a
"quoted" string in the filter.
One that properly, quotes: single quote, double quote, square bracket &
other characters to be used in the Filter & other properties of the DataSet
Object Model.
Hope this helps
Jay
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:Oy**************@TK2MSFTNGP09.phx.gbl... newbie_csharp,
I believe you will have to double up on the quotes, like this:
// Alter the string so that it can be included in the filter. filterString = mysearch.Replace(@"'", @"''");
An then search on that.
I personally don't like this, and have suggested a number of times to people at MS that they provide something like parameters for this kind of operation (so that we could pass CLR types and not have to worry about conversions like this).
Hope this helps.
-- - Nicholas Paldino [.NET/C# MVP] - mv*@spam.guard.caspershouse.com
"newbie_csharp" <an*******@devdex.com> wrote in message news:%2***************@tk2msftngp13.phx.gbl... Hi, I need to use single qoutation ( ' ) in my filter string but I get error message. how can I do something like this:
mysearch = "Bob's book"; dataView.RowFilter = "myfield LIKE '" + mysearch + "%'";
even I changed "mysearch to this but still it's not working:
mysearch = "Bob\'s book";
thanks *** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it!
Jay,
I don't think that an escape function is enough, as it would still force
me to concatenate parts of my expression together, something I wouldn't have
to do for a command to a database.
And yes, anywhere the Expression property is relevant, and handles all
types in the framework that can be stored in a dataset.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message
news:%2******************@TK2MSFTNGP15.phx.gbl... Nicholas, Parameters or even simply an Encode/Escape function (like Regex.Escape & Regex.Unescape) that properly encodes the string so it works correctly as a "quoted" string in the filter.
One that properly, quotes: single quote, double quote, square bracket & other characters to be used in the Filter & other properties of the DataSet Object Model.
Hope this helps Jay
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in message news:Oy**************@TK2MSFTNGP09.phx.gbl... newbie_csharp,
I believe you will have to double up on the quotes, like this:
// Alter the string so that it can be included in the filter. filterString = mysearch.Replace(@"'", @"''");
An then search on that.
I personally don't like this, and have suggested a number of times to people at MS that they provide something like parameters for this kind of operation (so that we could pass CLR types and not have to worry about conversions like this).
Hope this helps.
-- - Nicholas Paldino [.NET/C# MVP] - mv*@spam.guard.caspershouse.com
"newbie_csharp" <an*******@devdex.com> wrote in message news:%2***************@tk2msftngp13.phx.gbl... Hi, I need to use single qoutation ( ' ) in my filter string but I get error message. how can I do something like this:
mysearch = "Bob's book"; dataView.RowFilter = "myfield LIKE '" + mysearch + "%'";
even I changed "mysearch to this but still it's not working:
mysearch = "Bob\'s book";
thanks *** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it!
Nicholas,
The escape function itself could do the concatenation, by accepting a format
string & params args, similar to String.Format.
Something like:
mysearch = "Bob's book";
dataView.RowFilter = Escape("myfield LIKE '{0}%'", mysearch);
Otherwise I totally agree, a full parameters collection would be better!
Jay
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:OI**************@TK2MSFTNGP09.phx.gbl... Jay,
I don't think that an escape function is enough, as it would still force me to concatenate parts of my expression together, something I wouldn't have to do for a command to a database.
And yes, anywhere the Expression property is relevant, and handles all types in the framework that can be stored in a dataset.
-- - Nicholas Paldino [.NET/C# MVP] - mv*@spam.guard.caspershouse.com
"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message news:%2******************@TK2MSFTNGP15.phx.gbl... Nicholas, Parameters or even simply an Encode/Escape function (like Regex.Escape & Regex.Unescape) that properly encodes the string so it works correctly as a "quoted" string in the filter.
One that properly, quotes: single quote, double quote, square bracket & other characters to be used in the Filter & other properties of the DataSet Object Model.
Hope this helps Jay
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in message news:Oy**************@TK2MSFTNGP09.phx.gbl... newbie_csharp,
I believe you will have to double up on the quotes, like this:
// Alter the string so that it can be included in the filter. filterString = mysearch.Replace(@"'", @"''");
An then search on that.
I personally don't like this, and have suggested a number of times to people at MS that they provide something like parameters for this kind of operation (so that we could pass CLR types and not have to worry about conversions like this).
Hope this helps.
-- - Nicholas Paldino [.NET/C# MVP] - mv*@spam.guard.caspershouse.com
"newbie_csharp" <an*******@devdex.com> wrote in message news:%2***************@tk2msftngp13.phx.gbl... Hi, I need to use single qoutation ( ' ) in my filter string but I get error message. how can I do something like this:
mysearch = "Bob's book"; dataView.RowFilter = "myfield LIKE '" + mysearch + "%'";
even I changed "mysearch to this but still it's not working:
mysearch = "Bob\'s book";
thanks *** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it!
Jay:
Shouldn't you be paying attention to the DevCon speaker instead of
hanging out in a newsgroup? :)
--
Scott http://www.OdeToCode.com/blogs/scott/
P.S. No, I didn't make it there, but I am jealous. Nicholas, The escape function itself could do the concatenation, by accepting a format string & params args, similar to String.Format.
Something like: mysearch = "Bob's book"; dataView.RowFilter = Escape("myfield LIKE '{0}%'", mysearch);
Otherwise I totally agree, a full parameters collection would be better!
Jay
Scott,
?
I'm not at DevCon, so how would I be able to pay attention to the speaker?
Jay
"Scott Allen" <bitmask@[nospam].fred.net> wrote in message
news:2a********************************@4ax.com... Jay:
Shouldn't you be paying attention to the DevCon speaker instead of hanging out in a newsgroup? :)
-- Scott http://www.OdeToCode.com/blogs/scott/
P.S. No, I didn't make it there, but I am jealous.
Nicholas, The escape function itself could do the concatenation, by accepting a format string & params args, similar to String.Format.
Something like: mysearch = "Bob's book"; dataView.RowFilter = Escape("myfield LIKE '{0}%'", mysearch);
Otherwise I totally agree, a full parameters collection would be better!
Jay
Opps - wrong Jay. Sorry for the confusion :)
On Wed, 20 Oct 2004 22:41:48 -0500, "Jay B. Harlow [MVP - Outlook]"
<Ja************@msn.com> wrote: Scott, ?
I'm not at DevCon, so how would I be able to pay attention to the speaker?
Jay
"Scott Allen" <bitmask@[nospam].fred.net> wrote in message news:2a********************************@4ax.com.. . Jay:
Shouldn't you be paying attention to the DevCon speaker instead of hanging out in a newsgroup? :)
-- Scott http://www.OdeToCode.com/blogs/scott/
P.S. No, I didn't make it there, but I am jealous.
Nicholas, The escape function itself could do the concatenation, by accepting a format string & params args, similar to String.Format.
Something like: mysearch = "Bob's book"; dataView.RowFilter = Escape("myfield LIKE '{0}%'", mysearch);
Otherwise I totally agree, a full parameters collection would be better!
Jay
--
Scott http://www.OdeToCode.com/ This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Jim Heimer |
last post by:
When I use the dataview.rowfilter and I try to display the field value of
the first row, the code doesn't seem to show the first row AFTER the
rowfilter.
This is my code:
DataView...
|
by: Randy |
last post by:
Hello All,
I'm trying to use a DataView and in the rowfilter, base it on two fields in
the table. I can't find any examples on this. Is there a way to do it. I'm
talking about something like......
|
by: Webgour |
last post by:
I'm tring to filter a dataview with multiple rowfilters. The problem is that
each time I use RowFilter on the DataView i'm quering the full dataview as
it was loaded, not the filtered version. Is...
|
by: Vern |
last post by:
The following code retrieves data into a dataset, and then creates a dataview
with a filter. This dataview is then attached to a combobox. When the
effective date changes, I would like to see the...
|
by: David |
last post by:
Hi, I use DataView to filter my record.
But when I use:
ls_filter += " and DATEPART(hh, CA103)=" + i ;
mydv.RowFilter = ls_filter;
I got error.
How should I filter by hour using...
|
by: Siegfried Heintze |
last post by:
I'm displaying information on job postings in various cities. For example,
might have a dozen jobs in Atlanta GA and I decide, at run time, that I
don't want to see them. How do I set my DataView...
|
by: Able |
last post by:
Dear friends
Dim myDataView as DataView = New DataView(dsData.Tables("tblCustomers"))
myDataView.RowFilter = "City = 'London'"
My question is how to loop through all rows in myDataView and...
|
by: KC |
last post by:
For a DataView.Rowfilter can I use more than one expression? I want to
filter out two different things.
For example can I take:
dv.RowFilter = "MTX <> 'Customer Forcast'"
and
...
|
by: =?Utf-8?B?cG1jZ3VpcmU=?= |
last post by:
I have a dataset with 3 tables -- 2 Parent tables and 1 table that is a child
table of both the parents. I create a dataview on the child table and set
the rowfilter to a value which filters the...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
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: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
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,...
| |