473,671 Members | 2,209 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 54603
Yes, you can use a dataview and set it's rowfilter.

DataView dv = myDataTable.Def aultView;
dv.RowFilter = "FirstField LIKE 'whatever%'"
"TA" <TA@ta.com> wrote in message
news:e1******** ******@TK2MSFTN GP09.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.Selec t 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.Selec t, otherwise
I normally use the DataView.

Hope this helps
Jay

"TA" <TA@ta.com> wrote in message
news:e1******** ******@TK2MSFTN GP09.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.Selec t("Name like '%rob%'");

"TA" <TA@ta.com> wrote in message
news:e1******** ******@TK2MSFTN GP09.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******** ******@tk2msftn gp13.phx.gbl...
TA,
In addition to the DataView as William stated, you can also use the
DataTable.Selec t 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.Selec t, otherwise I normally use the DataView.

Hope this helps
Jay

"TA" <TA@ta.com> wrote in message
news:e1******** ******@TK2MSFTN GP09.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.Expr ession.

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

Hope this helps
Jay

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

"TA" <TA@ta.com> wrote in message
news:e1******** ******@TK2MSFTN GP09.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
11189
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. Now, how do I modify the Person class (which interfaces to implement) so I can bind my DataTable to a DataGrid and then add, modify and delete records through it?
3
4736
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 1 21 12 32 2 1 43 12 3 32 12 35 I need to output:
2
3171
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 no option to sort the different columns during the call to the component.
1
4034
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 what I am trying to do... ---------
2
2469
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 which the third one is blank): id Number Description 1 1 Desc1 2 1 Desc2
3
7144
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 = dtRvDetail.Select("check = false ") Me.dtRvDetail.Rows.Remove(myDelRowArray) <-- I know there is error, since i cannot delete the datarowarray. Any simple and easy way ?? thanks a lot
2
9046
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'); I am getting the above error. I feel that because the column name is containing '+' sign, I am getting this error. If the column name does not contain + sign then the filtering is working fine for me.
6
2128
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 not filtering out all the other acrynyms in actuallity it is doing nothing at all. This table is a linked ODCB connection will this affect filtering using the like statement?
1
4840
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 code about 2 seconds to report back. But when I put a LIKE filter in the DataTable.Select() it suddenly takes 38 seconds. This only happens when I use a LIKE statement, any other statement is no problem. Do you guys have any idea how to tweak this? ...
0
8393
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8820
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8598
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6223
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5695
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4224
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2810
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
2
2051
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1809
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.