|
|
|
start date: Tue, 10 Jul 2007 12:33:28 -0400,
posted on: microsoft.public.dotnet.framework.adonet
back
| Thread Index |
|
1
Earl am
|
|
2
Patrice http://www.chez.com/scribe/
|
|
3
Patrice http://www.chez.com/scribe/
|
|
4
Earl am
|
|
5
Earl am
|
Why double escape for apostrophe?
Anyone know why the RowFilter has to be double-escaped? Anticipating names
with apostrophes, a single escape does not provide the proper name to filter
on.
For example, this would cause an exception:
Dim strname As String
strname = txtContact.Text
strname.Replace("'", "''")
dv.RowFilter = "ContactFullName='" + strname + "'"
.... but this would provide the proper filter:
dv.RowFilter = "ContactFullName='"" + strname + ""'"
Note the comma before the double quotes on the inside before the apostrophe
and the double quotes after the apostrophe on the outside.
Date:Tue, 10 Jul 2007 12:33:28 -0400
Author:
|
Re: Why double escape for apostrophe?
Use :
strName=strName.Replace("'","''")
Keep in mind that strings are immutable i.e. are never changed that is the
Replace *function* returns a new string. It doesn't change the existing
string.
---
Patrice
"Earl" <brikshoe@newsgroups.nospam> a crit dans le message de news:
uYwiP%23wwHHA.840@TK2MSFTNGP03.phx.gbl...
> Anyone know why the RowFilter has to be double-escaped? Anticipating names
> with apostrophes, a single escape does not provide the proper name to
> filter on.
>
> For example, this would cause an exception:
> Dim strname As String
> strname = txtContact.Text
> strname.Replace("'", "''")
> dv.RowFilter = "ContactFullName='" + strname + "'"
>
> ... but this would provide the proper filter:
> dv.RowFilter = "ContactFullName='"" + strname + ""'"
>
> Note the comma before the double quotes on the inside before the
> apostrophe and the double quotes after the apostrophe on the outside.
>
Date:Tue, 10 Jul 2007 18:37:27 +0200
Author:
|
Re: Why double escape for apostrophe?
Use :
strName=strName.Replace("'","''")
Keep in mind that strings are immutable i.e. are never changed that is the
Replace *function* returns a new string. It doesn't change the existing
string.
---
Patrice
"Earl" <brikshoe@newsgroups.nospam> a crit dans le message de news:
uYwiP%23wwHHA.840@TK2MSFTNGP03.phx.gbl...
> Anyone know why the RowFilter has to be double-escaped? Anticipating names
> with apostrophes, a single escape does not provide the proper name to
> filter on.
>
> For example, this would cause an exception:
> Dim strname As String
> strname = txtContact.Text
> strname.Replace("'", "''")
> dv.RowFilter = "ContactFullName='" + strname + "'"
>
> ... but this would provide the proper filter:
> dv.RowFilter = "ContactFullName='"" + strname + ""'"
>
> Note the comma before the double quotes on the inside before the
> apostrophe and the double quotes after the apostrophe on the outside.
>
Date:Tue, 10 Jul 2007 18:37:27 +0200
Author:
|
Re: Why double escape for apostrophe?
Thanks Patrice.
"Patrice" <http://www.chez.com/scribe/> wrote in message
news:OnRxbCxwHHA.4568@TK2MSFTNGP03.phx.gbl...
> Use :
> strName=strName.Replace("'","''")
>
> Keep in mind that strings are immutable i.e. are never changed that is the
> Replace *function* returns a new string. It doesn't change the existing
> string.
>
> ---
> Patrice
>
>
> "Earl" <brikshoe@newsgroups.nospam> a crit dans le message de news:
> uYwiP%23wwHHA.840@TK2MSFTNGP03.phx.gbl...
>> Anyone know why the RowFilter has to be double-escaped? Anticipating
>> names with apostrophes, a single escape does not provide the proper name
>> to filter on.
>>
>> For example, this would cause an exception:
>> Dim strname As String
>> strname = txtContact.Text
>> strname.Replace("'", "''")
>> dv.RowFilter = "ContactFullName='" + strname + "'"
>>
>> ... but this would provide the proper filter:
>> dv.RowFilter = "ContactFullName='"" + strname + ""'"
>>
>> Note the comma before the double quotes on the inside before the
>> apostrophe and the double quotes after the apostrophe on the outside.
>>
>
>
Date:Tue, 10 Jul 2007 18:30:13 -0400
Author:
|
Re: Why double escape for apostrophe?
Thanks Patrice.
"Patrice" <http://www.chez.com/scribe/> wrote in message
news:OnRxbCxwHHA.4568@TK2MSFTNGP03.phx.gbl...
> Use :
> strName=strName.Replace("'","''")
>
> Keep in mind that strings are immutable i.e. are never changed that is the
> Replace *function* returns a new string. It doesn't change the existing
> string.
>
> ---
> Patrice
>
>
> "Earl" <brikshoe@newsgroups.nospam> a crit dans le message de news:
> uYwiP%23wwHHA.840@TK2MSFTNGP03.phx.gbl...
>> Anyone know why the RowFilter has to be double-escaped? Anticipating
>> names with apostrophes, a single escape does not provide the proper name
>> to filter on.
>>
>> For example, this would cause an exception:
>> Dim strname As String
>> strname = txtContact.Text
>> strname.Replace("'", "''")
>> dv.RowFilter = "ContactFullName='" + strname + "'"
>>
>> ... but this would provide the proper filter:
>> dv.RowFilter = "ContactFullName='"" + strname + ""'"
>>
>> Note the comma before the double quotes on the inside before the
>> apostrophe and the double quotes after the apostrophe on the outside.
>>
>
>
Date:Tue, 10 Jul 2007 18:30:13 -0400
Author:
|
|
|