DotNetNewsgroup.com  
web access to complete list of Microsoft.NET newsgroups
   home   |   control panel login   |   archive  |  
 
  carried group
academic
adonet
aspnet
aspnet.announcements
aspnet.buildingcontrols
aspnet.caching
aspnet.datagridcontrol
aspnet.mobile
aspnet.security
aspnet.webcontrols
aspnet.webservices
assignment_manager
datatools
dotnet.distributed_apps
dotnet.general
dotnet.myservices
dotnet.nternationalization
dotnet.scripting
dotnet.security
dotnet.vjsharp
dotnet.vsa
dotnet.xml
dotnetfaqs
framework
framework.clr
framework.compactframework
framework.component_services
framework.controls
framework.databinding
framework.drawing
framework.enhancements
framework.interop
framework.odbcnet
framework.performance
framework.remoting
framework.sdk
framework.setup
framework.webservices
framework.windowsforms
framework.wmi
frwk.windowsforms.designtime
lang.csharp
lang.jscript
lang.vb
lang.vb.controls
lang.vb.data
lang.vb.upgrade
lang.vc
lang.vc.libraries
  
 
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:  

Google
 
Web dotnetnewsgroup.com


COPYRIGHT ?2005, EUROFRONT WORLDWIDE LTD., ALL RIGHT RESERVE  |   Contact us