Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Using Replace function in DataTable.Select

Reply
Thread Tools

Using Replace function in DataTable.Select

 
 
ArunDhaJ
Guest
Posts: n/a
 
      07-03-2008
Hi,
I'm having a DataTable with a column named "Phones" having value like

(901) 789 1234<BR>(901) 789 1235<BR>(901) 789 1221

I need to perform filtering based on the phone number of the form
"9017891221" or "7891221"

The following query works fine when tested in SQL but fails saying
that it doesnt support REPLACE() function

DataTable.Select("REPLACE(REPLACE(REPLACE(Phones, ' ', ''), '(' , ''),
')', '') like '%7891221%'")

Actually I'm replacing all formating strings from the field,
performing search from formatted string as converted as below:
9017891234<BR>9017891235<BR>9017891221.

Please suggest me if i've done wrong or provide me any alternate for
Replace function.

Thanks in Advance
-ArunDhaJ
 
Reply With Quote
 
 
 
 
bruce barker
Guest
Posts: n/a
 
      07-03-2008
as y9ou are querying a datatable, not sql, you need to use a valid query.
here are all the column filters you can use:

http://msdn.microsoft.com/en-us/libr...xpression.aspx

you could do the replace in sql before loading the table, or use linq, and
write a .net function to do the logic.

-- bruce (sqlwork.com)


"ArunDhaJ" wrote:

> Hi,
> I'm having a DataTable with a column named "Phones" having value like
>
> (901) 789 1234<BR>(901) 789 1235<BR>(901) 789 1221
>
> I need to perform filtering based on the phone number of the form
> "9017891221" or "7891221"
>
> The following query works fine when tested in SQL but fails saying
> that it doesnt support REPLACE() function
>
> DataTable.Select("REPLACE(REPLACE(REPLACE(Phones, ' ', ''), '(' , ''),
> ')', '') like '%7891221%'")
>
> Actually I'm replacing all formating strings from the field,
> performing search from formatted string as converted as below:
> 9017891234<BR>9017891235<BR>9017891221.
>
> Please suggest me if i've done wrong or provide me any alternate for
> Replace function.
>
> Thanks in Advance
> -ArunDhaJ
>

 
Reply With Quote
 
 
 
 
ArunDhaJ
Guest
Posts: n/a
 
      07-04-2008
Hi Bruce,
Actually I'm not loading from the table, but from the XML which i
receive in this format. So I've no other option filtering here. If it
doesnt support Replace() is there any other way to perform such
operation. I hvent used linq.

-ArunDhaJ
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Replace /n with a XHTML <br /> using string.replace Alun ASP .Net 3 02-18-2008 05:52 AM
how to make replace function replace globally in a string V S Rawat Javascript 5 07-03-2007 08:02 PM
Re: [Pyrex] pyrex functions to replace a method (Re: replace a method Greg Ewing Python 2 06-29-2006 05:25 PM
pyrex functions to replace a method (Re: replace a method in class:how?) Brian Blais Python 1 06-27-2006 12:13 PM
replace text in IFRAME using innerHTML.replace(...) possible? mscir Javascript 0 10-11-2005 11:21 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57