By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,234 Members | 1,908 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,234 IT Pros & Developers. It's quick & easy.

"top" of datatable (newby)

P: n/a
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
Share this Question
Share on Google+
3 Replies


P: n/a
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

P: n/a
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

P: n/a
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.