Click here to Skip to main content
15,880,469 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
I am using DataView.Rowfilter for getting one single row from a table for particular condition.
It's taking too much time, because I'm referring a table of thousand records around five hundred times...

Is there any other way to reduce the time for same functionality?
If we use for loop whether it will reduce the time?
Posted
Updated 15-Jan-11 2:00am
v3
Comments
Dalek Dave 15-Jan-11 8:00am    
Edited for Grammar and Clarity.

Why don't try you using LINQ instead?

Even better, try using multiple threads in a thread pool to do it.
 
Share this answer
 
Comments
Espen Harlinn 16-Jan-11 8:34am    
I think he mentioned "taking much time.!!!!" - I somehow fail to see how linq can improve the speed of the application. As Dave points out - using the database engine/server solves this efficiently.
#realJSOP 17-Jan-11 6:04am    
Just suggesting another option. Without sitting down and trying to actually duplicate what he's doing, it's impossible to answer with any kind of authority.
Yeah, scrap your design and redo it. If you're filtering throught thousands of rows, you're forcing RowFilter to look at each and every one of those records.

The DataTable is not indexed, so there's no way to speed it up using RowFilter. If you insist on using RowFilter, you're going to have to create your own index on the table, besed on your filter criteria, then implement a method that emulates RowFilter and uses this index to find the row it needs faster.

Or, you could skip all this work and do it the easy way by having the database find that one record for you, MUCH faster than a DataView could.
 
Share this answer
 
Comments
Simon_Whale 15-Jan-11 17:31pm    
as always sound advice

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900