PC Review


Reply
Thread Tools Rate Thread

DataTable - the order of rows.

 
 
Dobieslaw Wroblewski
Guest
Posts: n/a
 
      4th Dec 2004
Hello,

I am adding rows to the data table without primary key defined using the
DataRowCollection.Add(object[]) method.

When I am reading the table directly or using its default view or a view
with order set to "", I would like to process the records exactly in the
order in which they were added.

The question is whether I can trust the actual order of rows or it might be
implementation-dependent?

DW.



 
Reply With Quote
 
 
 
 
Darren Shaffer
Guest
Posts: n/a
 
      4th Dec 2004
You can trust the order of the rows inserted into the DataTable if you
iterate
through the DataRowCollection of the DataTable when you go to read the
table.
There is no need to use a View unless you want to perform sorting,
filtering, or
querying on the DataTable.

-Darren Shaffer


"Dobieslaw Wroblewski" <dobieslaw.wroblewski@reverse_the_next.com.cegedim>
wrote in message news:coskmt$mpr$(E-Mail Removed)...
> Hello,
>
> I am adding rows to the data table without primary key defined using the
> DataRowCollection.Add(object[]) method.
>
> When I am reading the table directly or using its default view or a view
> with order set to "", I would like to process the records exactly in the
> order in which they were added.
>
> The question is whether I can trust the actual order of rows or it might
> be
> implementation-dependent?
>
> DW.
>
>
>



 
Reply With Quote
 
Dobieslaw Wroblewski
Guest
Posts: n/a
 
      5th Dec 2004
Thanks for the answer.

> You can trust the order of the rows inserted
> into the DataTable if you iterate
> through the DataRowCollection of the
> DataTable when you go to read the table.


No matter if I use "for" or "foreach"?


> There is no need to use a View unless you want to perform sorting,
> filtering, or querying on the DataTable.


I think I might need filtering, but I would like the insertion order to be
preserved all the same.

Of course I might add an additional field keeping the insertion order and
use it for sorting, but anyway, it is more work and more usage of memory.

DW.


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
DataTable.Select vs DataTable.rows.Find vs foreach Dave Microsoft C# .NET 1 17th May 2007 09:06 PM
Setting the order of rows stored in a DataTable =?Utf-8?B?VG9tVQ==?= Microsoft ADO .NET 8 3rd Aug 2006 08:34 AM
DataTable.Select() - is it possible to pass rows back to datatable =?Utf-8?B?QW5kcmUgUmFuaWVyaQ==?= Microsoft ADO .NET 5 9th Nov 2005 05:10 PM
DataTable - order of rows. Dobieslaw Wroblewski Microsoft Dot NET Framework 2 6th Dec 2004 02:47 PM
How can I use real SQL on a DataTable? i.e. not array of rows using a filter... as in DataTable.Select Dan V. Microsoft C# .NET 3 1st Jul 2004 03:06 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:19 PM.