473,320 Members | 1,957 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Using Replace function in DataTable.Select

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
Jul 3 '08 #1
2 11576
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
Jul 3 '08 #2
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
Jul 4 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: K.Simon | last post by:
Hello, it's very often neccessary to replace strings or a single character in my stylesheets. My solution looks awful and very long. Now i thought to solve this with an array like structure but...
4
by: Japhy | last post by:
Hello, I'm am pulling data from a mysql db and want to use the data to populate a <ul. Here are relavent parts of my code : $wohdate = mysql_result($wohRS,$wohndx,woh_date); $woh_display...
11
by: Grasshopper | last post by:
Hi, I am automating Access reports to PDF using PDF Writer 6.0. I've created a DTS package to run the reports and schedule a job to run this DTS package. If I PC Anywhere into the server on...
0
by: Rodusa | last post by:
I am trying to replace cookies with the new "Asp.net 2.0 profiles" in my shopping cart application, but I am having trouble to access profile properties using HttpContext.Current.Profile. I can...
8
by: John | last post by:
Hi I need to be able to call a web service method, receive the dataset that web method returns and store it in an access table. My problem is that I don't know how to "receive" a complex type...
6
by: ransoma22 | last post by:
I developing an application that receive SMS from a connected GSM handphone, e.g Siemens M55, Nokia 6230,etc through the data cable. The application(VB.NET) will receive the SMS automatically,...
2
by: TB | last post by:
Before displaying the result of a table called "people" in a datagrid called "mydatagrid", I need to modify the content of a column called "moreinfo" in the in-memory datatable (but not the...
3
by: Niyazi | last post by:
Hi all, I have a dataTable that contains nearly 38400 rows. In the dataTable consist of 3 column. column 1 Name: MUHNO column 2 Name: HESNO Column 3 Name: BALANCE Let me give you some...
1
by: pnbaocuong | last post by:
Dear All When I try to use convert function of MS sql server like this: String sql = " (employee_id = '" + employee_id + "') and ((convert(VARCHAR,w_date,103) = '" + w_date + "'))"; ...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.