473,387 Members | 1,493 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,387 software developers and data experts.

Datatable search

I have a datatable with different id's in it. Each id has a set of
attribute pairs.

EG

id - attribute name - attribute value
========================
dog -legs - 4
dog - barks - true
cat - legs - 4
cat - barks - false
I simple want to query the table, like in sql, and select an attribute
by id.

eg: select attribute value where id=cat and attribute name =legs

to find out how many legs a cat has got.

Is there an easy way to do this with a datatable?
Thanks

Jun 29 '06 #1
1 2176
Yes, there is. See the Select method on the DataTable class. The
documentation for the method will tell you the syntax you need to use to
filter on this.

You might also want to consider a DataView as well, depending on what
you are going to do with it.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

<ar*********@gmail.com> wrote in message
news:11**********************@d56g2000cwd.googlegr oups.com...
I have a datatable with different id's in it. Each id has a set of
attribute pairs.

EG

id - attribute name - attribute value
========================
dog -legs - 4
dog - barks - true
cat - legs - 4
cat - barks - false
I simple want to query the table, like in sql, and select an attribute
by id.

eg: select attribute value where id=cat and attribute name =legs

to find out how many legs a cat has got.

Is there an easy way to do this with a datatable?
Thanks

Jun 29 '06 #2

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

Similar topics

9
by: VMI | last post by:
We have this huge application that's based on storing tons of data on a dataTable. The only problem we're having is that storing LOTS of data (1 million records) into a datatable will slow down the...
2
by: pagates | last post by:
Hi All, I have a DataTable in a Windows Forms project that I would like to use a Select statement. The problem is, I'd like to be able to do wildcard searches (including single charcater...
3
by: Magnus | last post by:
I have a datatable (I will call it 'main' datatable) with records that have child rows. I need to select all the records from the main datatable where the record/row has a childrow that meets a...
4
by: Brett Romero | last post by:
I fill a DataTable with search results, which take a very long time if I first clear it. The values come from an object and I map them into the corresponding table columns. I may have 65000...
4
by: Rich | last post by:
Hello, I need to store various values that I will need to look up later on. I have been using hashtables and arraylists. But I can only store 2 items per row in a hashtable - key, value, and...
4
by: oopman2002 | last post by:
I have created a DataSet DataTable which is comprised of data from a number of sources. The resultant datatable is about 500,000 records and writing them out one at a time takes forever. Does...
2
by: Larry Smith | last post by:
Hi there, Can anyone comment on the performance issues of "DataTable.Select()" vs "DataView.Find()" (or "DataView.FindRows()"). I have to conduct repeated searches using the same index and I'm...
4
by: piercy | last post by:
i need to extract a value from a datatable. in the datatable there are two values ID and AdmissionNumber. i have the admission number but i need to get the id number from the table. how would i be...
4
by: ArunDhaJ | last post by:
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...
9
by: =?Utf-8?B?anAybXNmdA==?= | last post by:
I've got a routine that builds a table using different queries, different SQL Tables, and adding custom fields. It takes a while to run (20 - 45 seconds) so I wrote a thread to handle the table...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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...
0
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,...

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.