473,513 Members | 2,514 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DataTable filtering (Like)

TA
Hi,

Does anyone know if it is possible to filter rows in a DataTable by pattern
(e.g. Like in SQL)

For instance I want to select all rows containing the 'rob' in the name
column.

Any ideas?
- TA
Nov 16 '05 #1
5 54592
Yes, you can use a dataview and set it's rowfilter.

DataView dv = myDataTable.DefaultView;
dv.RowFilter = "FirstField LIKE 'whatever%'"
"TA" <TA@ta.com> wrote in message
news:e1**************@TK2MSFTNGP09.phx.gbl...
Hi,

Does anyone know if it is possible to filter rows in a DataTable by pattern (e.g. Like in SQL)

For instance I want to select all rows containing the 'rob' in the name
column.

Any ideas?
- TA

Nov 16 '05 #2
TA,
In addition to the DataView as William stated, you can also use the
DataTable.Select method to return an array of DataRows.

The biggest difference being is the DataView is bindable, while the Select
is not.

If I need the rows in a For Each I normally use DataTable.Select, otherwise
I normally use the DataView.

Hope this helps
Jay

"TA" <TA@ta.com> wrote in message
news:e1**************@TK2MSFTNGP09.phx.gbl...
Hi,

Does anyone know if it is possible to filter rows in a DataTable by pattern (e.g. Like in SQL)

For instance I want to select all rows containing the 'rob' in the name
column.

Any ideas?
- TA

Nov 16 '05 #3
TA
found it
like really exists
e.g. dataTable.Select("Name like '%rob%'");

"TA" <TA@ta.com> wrote in message
news:e1**************@TK2MSFTNGP09.phx.gbl...
Hi,

Does anyone know if it is possible to filter rows in a DataTable by pattern (e.g. Like in SQL)

For instance I want to select all rows containing the 'rob' in the name
column.

Any ideas?
- TA

Nov 16 '05 #4
TA
Thanks guys,
Appreciate teh Help

"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message
news:Oh**************@tk2msftngp13.phx.gbl...
TA,
In addition to the DataView as William stated, you can also use the
DataTable.Select method to return an array of DataRows.

The biggest difference being is the DataView is bindable, while the Select
is not.

If I need the rows in a For Each I normally use DataTable.Select, otherwise I normally use the DataView.

Hope this helps
Jay

"TA" <TA@ta.com> wrote in message
news:e1**************@TK2MSFTNGP09.phx.gbl...
Hi,

Does anyone know if it is possible to filter rows in a DataTable by

pattern
(e.g. Like in SQL)

For instance I want to select all rows containing the 'rob' in the name
column.

Any ideas?
- TA


Nov 16 '05 #5
TA,
FYI: The syntax that ADO.NET supports for Expressions (such as those passed
to
Select & Compute) is documented under DataColumn.Expression.

http://msdn.microsoft.com/library/de...ssionTopic.asp

Hope this helps
Jay

"TA" <TA@ta.com> wrote in message
news:Ov****************@TK2MSFTNGP12.phx.gbl...
found it
like really exists
e.g. dataTable.Select("Name like '%rob%'");

"TA" <TA@ta.com> wrote in message
news:e1**************@TK2MSFTNGP09.phx.gbl...
Hi,

Does anyone know if it is possible to filter rows in a DataTable by

pattern
(e.g. Like in SQL)

For instance I want to select all rows containing the 'rob' in the name
column.

Any ideas?
- TA


Nov 16 '05 #6

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

Similar topics

5
11182
by: Dalibor Kusic | last post by:
The DataTable contains, for example, only one column of lets say Person class. Person class has three fields, and a constructor that takes a single string and parses it over those three fields. ...
3
4729
by: Matthew Wieder | last post by:
I have a datatable as a source and I need to produce a datatable which is all the rows in the original datatable except the first row, copied n times. So, if I had a datatable of: A B C...
2
3163
by: Fredrik Rodin | last post by:
All, I've been looking around for a solution to my problem for a couple of days now. In short, here's my situation: 1. I'm getting a result from a component back as a datatable and I have...
1
4019
by: Diffident | last post by:
Hello All, I am trying to filter rows in a datatable based on filtercriteria and sortcriteria using the datatable.select() method. I am encountering a strange behavior in this process. Here is...
2
2451
by: Roy | last post by:
Hi all, I do have a datatable that looks like: id Number Description 1 1 Desc1 2 1 Desc2 3 2 Desc3 I need this datatable looks like (with 4 rows...
3
7137
by: Agnes | last post by:
I need to Load 4thousand record into a datagrid for the user to choose. After the user click the row, I will save it. Now, How can I remove the uncheck row. Dim myDelRowArray() As DataRow =...
2
9016
by: alice123 | last post by:
I have a DataTable with ColumnName: ++CustomerName++. when i try to filter this DataTable as string columnName=Table.Columns.ToString(); DataRow row = Table.Select(columnName + " = 'Alice'); ...
6
2117
by: Ron Mowry | last post by:
I have a linked table I am attempting to filter data out of. One of my field has several acronyms and I am looking only for 1 specificly "XTL" When I use the like "XTL" in the criteria field it is...
1
4795
by: Cappamontana | last post by:
Hi, I have a question for those who have some experience with select LIKE statements on huge data (about 200 million rows). When I run some computing and filtering on this table, it takes the...
0
7384
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7539
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...
0
7527
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5090
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...
0
4746
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...
0
3234
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3223
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1597
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 ...
0
456
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...

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.