472,984 Members | 2,188 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

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>9017891235<BR>9017891221
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 4069
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>9017891235<BR>9017891221
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.Select() 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 insignificantCharacters = new Regex("[() ]");
IEnumerable<DataRowresult =
from row in dt.AsEnumerable()
let phones = row.Field<string>("Phone").Split(new[] {"<BR>"},
StringSplitOptions.None).Select(phone =>
insignificantCharacters.Replace(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
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....
9
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...
0
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...
0
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...
1
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...
7
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
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...
9
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...
6
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...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
4
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

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.