472,110 Members | 2,203 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,110 software developers and data experts.

"top" of datatable (newby)

Hi:

I have created a datatable and I'm able to access it by key values.

I need to be able to go to the "top" of the datatable and process
records sequentially until they are completed.

I can't figure out the command to set me to the top or "beginning" and
then read. (datatable.select?)

Any help in the steps to do this would be greatly appreciated!

Thanks,

Fred
Nov 20 '05 #1
3 1635
I solved it - it was too easy:

dim myDataView as new dataview(mytable)

Thanks!
Fred Nelson wrote:
Hi:

I have created a datatable and I'm able to access it by key values.

I need to be able to go to the "top" of the datatable and process
records sequentially until they are completed.

I can't figure out the command to set me to the top or "beginning" and
then read. (datatable.select?)

Any help in the steps to do this would be greatly appreciated!

Thanks,

Fred

Nov 20 '05 #2
Fred,

Dataviews are good if you want to create a temporary filter. You still have
to create a loop to read through the file. Just to read the file from start
to finish most people use the following:

Dim dr As DataRow
For Each dr in MyTable
... Do something using "dr." to reference each field
Next

Regards
"Fred Nelson" <fr**@smartybird.com> wrote in message
news:%2***************@tk2msftngp13.phx.gbl...
Hi:

I have created a datatable and I'm able to access it by key values.

I need to be able to go to the "top" of the datatable and process
records sequentially until they are completed.

I can't figure out the command to set me to the top or "beginning" and
then read. (datatable.select?)

Any help in the steps to do this would be greatly appreciated!

Thanks,

Fred

Nov 20 '05 #3
Fred,
In addition to the other examples you can use:

Dim table As DataTable

For Each row As DataRow in table.Rows
' do something with the row
Next

For Each row As DataRow in table.Select()
' do something with the row
Next

Dim view As New DataView(table)
For Each row As DataRowView in view
' do something with the row
Next

Each is useful in their own right. Most of the time I use the first.
DataTable & DataView allow you to filter rows. The second is useful if you
want to delete selected rows, as DataTable.Select returns an array of rows,
allowing you to use DataRow.Delete to delete the row from the DataTable
itself, Also DataTable.Select is overloaded so you can sort & filter the
returned rows. The DataView has some very flexible sorting, searching, and
filtering abilities, plus you can bind to it.

I recommend David Sceppa's book "Microsoft ADO.NET - Core Reference" from MS
Press. As it is a good tutorial on ADO.NET as well as a good desk reference
once you know ADO.NET.

Hope this helps
Jay

"Fred Nelson" <fr**@smartybird.com> wrote in message
news:%2***************@tk2msftngp13.phx.gbl...
Hi:

I have created a datatable and I'm able to access it by key values.

I need to be able to go to the "top" of the datatable and process
records sequentially until they are completed.

I can't figure out the command to set me to the top or "beginning" and
then read. (datatable.select?)

Any help in the steps to do this would be greatly appreciated!

Thanks,

Fred

Nov 20 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

19 posts views Thread by Mason A. Clark | last post: by
6 posts views Thread by Mason A. Clark | last post: by
16 posts views Thread by Gufus | last post: by
16 posts views Thread by J. C. Denton | last post: by
9 posts views Thread by jensen bredal | last post: by
reply views Thread by leo001 | last post: by

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.