473,545 Members | 2,115 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DataTable Select - Undefined function error

Hi,
I've to filter rows from DataTable Select

There is a column named "Phone" which contains values in the following
format:
(901) 789 1234<BR>(901) 789 1235<BR>(901) 789 1221

I need to filter based on the phone number. the search criteria could
be 9017891221 or 891221.
this string should filter the above column

I've tried in SQL be replacing the '(', ')' and spaces as
9017891234<BR>9 017891235<BR>90 17891221
and performed search. It worked fine..

When i tried in Select method gives Unknown Function
REPLACE() error

I've used
REPLACE(REPLACE (REPLACE(Phones , ' ', ''), '(' , ''), ')', '') like
'%891221%'
Is there any way to achieve the same to filter the data?
Thanks in Advance
- ArunDhaJ
Jul 4 '08 #1
4 4120
On Jul 4, 6:50*pm, ArunDhaJ <arund...@gmail .comwrote:
Hi,
I've to filter rows from DataTable Select

There is a column named "Phone" which contains values in the following
format:
(901) 789 1234<BR>(901) 789 1235<BR>(901) 789 1221

I need to filter based on the phone number. the search criteria could
be 9017891221 or *891221.
this string should filter the above column

I've tried in SQL be replacing the '(', ')' and spaces as
9017891234<BR>9 017891235<BR>90 17891221
and performed search. It worked fine..

When i tried in Select method gives Unknown Function
REPLACE() error

I've used
REPLACE(REPLACE (REPLACE(Phones , ' ', ''), '(' , ''), ')', '') like
'%891221%'

Is there any way to achieve the same to filter the data?
Unfortunately, the syntax of the filter expression for
DataTable.Selec t() does not provide for any equivalent to REPLACE.
However, in .NET 3.5, you may use LINQ to DataSet to query, and
regexes to clean up the string:

DataTable dt = ...;
Regex insignificantCh aracters = new Regex("[() ]");
IEnumerable<Dat aRowresult =
from row in dt.AsEnumerable ()
let phones = row.Field<strin g>("Phone").Spl it(new[] {"<BR>"},
StringSplitOpti ons.None).Selec t(phone =>
insignificantCh aracters.Replac e(phone, ""))
where phones.Contains ("891221")
select row;

In .NET 2.0, you'll have to resort to writing the same thing manually
using foreach.
Jul 4 '08 #2
Hi,
would this operation in foreach loop would hit the performance?

manually looping in DataTable rows and removing those rows that doesnt
match may hit performance right?

-ArunDhaJ
Jul 5 '08 #3
On Jul 5, 8:53*am, ArunDhaJ <arund...@gmail .comwrote:
Hi,
would this operation in foreach loop would hit the performance?

manually looping in DataTable rows and removing those rows that doesnt
match may hit performance right?

-ArunDhaJ
Not very likely. DataTable is not a proper indexed data store, so
Select() will, most likely, just use foreach internally. If you need
to filter large data sets, you should use a proper relational
database, and do the filtering in SQL requests to that.
Jul 5 '08 #4
Thanks Pavel, I've implemented using foreach and it works fine now.

Sorry for delayed response... ;)

-ArunDhaJ
Jul 8 '08 #5

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

Similar topics

4
7383
by: bobsawyer | last post by:
I've been building a series of SELECT lists that are populated dynamically using HTTPRequest. Things are going pretty well, and I've got the whole thing working flawlessly in Mozilla/Firebird. Unfortunately, Internet Explorer doesn't quite work as expected -- it gives me an "invalid argument" error that I don't know how to fix. Here's the...
9
6598
by: Frank | last post by:
Hi, I use datatable.select to select row in a table in a dataset. I use an ampersand in the selectstring and get an error that it is unsupported. The statement works fine in the query analyzer of enterprise manager. select is like: '1 & val2' I use the & to have a binary AND comparison=to check if bit 0 of val2 is set. Do I make a mistake?...
0
1082
by: Jason MacKenzie | last post by:
If have a stored procedure that seems to work fine through query analyzer but if I attempt the same thing via code, no exceptions are thrown but no results are ever returned. I'm using the ODBC.NET dataprovider. The string that I cut and paste when I debug is: sp_OrgChart 1900,...
0
3130
by: Chris Ericoli | last post by:
Hi, I am working with an 'in session' ado dataset with an asp.net application. My dataset is comprised of two tables, one of which maintains a few calculated datacolumns. For some reason these datacolumns do not trigger their expression when other columns from which the expressions are derived are updated. Below is a basic example of what...
1
2009
by: cindy | last post by:
Get data into datatable, add to dataset dsSearch " Get data into datatable, add to dataset dsSearch Using In-Memory SQL Engine join the tables and select the filenames from the join, add to dataset dsSearch CODE ON http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=3994&lngWId=10 using SQL connection get data from view...
7
14978
by: wk6pack | last post by:
Hi, How do I check datatable.select(filter) in the following: for each dtrow in datatable.select(filter) .... next I've also tried:
10
3696
by: D. Shane Fowlkes | last post by:
I have a function that is called in page_load and the purpose of this function is to look up basic data in a MSSQL table and return it in the form of a datatable. The page_load will read the data and then fill a few simple labels. **Assuming** that I wrote the function properly, how exactly can I write the page_load sub to read the data...
9
12002
by: jsoques | last post by:
Hello, I created a Web Service using .Net 2.0 that has a function that returns a DataTable. I can test the function from the web page when I access the .asmx from a browser on localhost and it works. I can also test the function using VB6 and the xmlhttp activex object. The problem I have now is when using VS 2005 or VB.Net 2005 Express and...
6
3185
by: fniles | last post by:
I am using VB.NET 2005 and Access database. My program uses a timer that kicks in every 1 min to read from a database and copy the dataset table to a datatable. This database is in a class called clsStat.vb. Then I pass this class to a thread. Each thread will call a function inside the clsStat.vb to do a "Select" of the datatable. Every...
0
7468
marktang
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7808
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
5972
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5329
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4945
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3443
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1884
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1014
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
704
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.