Click here to Skip to main content
11,705,610 members (46,570 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: C# VB.NET DataRow
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 14-Jan-11 20:04pm
Edited 15-Jan-11 2:00am
Dalek Dave433.2K
Dalek Dave at 15-Jan-11 8:00am
Edited for Grammar and Clarity.
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Why don't try you using LINQ instead?

Even better, try using multiple threads in a thread pool to do it.
Espen Harlinn at 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.
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.
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

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.
Simon_Whale at 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)

  Print Answers RSS
0 OriginalGriff 213
1 Sergey Alexandrovich Kryukov 160
2 Inimicos 60
3 ProgramFOX 50
4 Richard MacCutchan 45
0 OriginalGriff 9,053
1 Sergey Alexandrovich Kryukov 8,347
2 CPallini 5,189
3 Maciej Los 4,726
4 Mika Wendelius 3,626

Advertise | Privacy | Mobile
Web03 | 2.8.150819.1 | Last Updated 15 Mar 2011
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100