Loop through all fields in a single record?

T

tedqn

In ASP, I can do it with

For Each objField In rsValue.Fields
//do something with objField.Value
Next

or
For i = 0 To rsValue.Fields.Count - 1 ..

I couldn't find any equivalent on how to do this with .net.
Can anybody help?
 
G

Guest

Well it depends on what kind of object you were looping through, e.g. to
loop through the columns in a DataTable object you could use something like
(in c#)

foreach(DataColumn CurrentColumn in MyDataTable.Columns)
{
Do something
}
 
T

tedqn

Thanks for the suggestion. I've decided to use Dataset so that I can
loop through all the table rows & cells. Not sure if I can get it into
a Datatable directly instead of having to specify dsXXX.Tables(0),
through a DataAdapter
 
?

=?ISO-8859-1?Q?G=F6ran_Andersson?=

Not sure if I can get it into
a Datatable directly instead of having to specify dsXXX.Tables(0),
through a DataAdapter

Declare a reference to a DataTable and make it reference the table you
want to use:

DataTable table
table = dsXXX.tables(0)
 
G

Guest

In ADO.net 1.x you have to put a table into a dataset before you can do
anything with it, in ADO.net 2.0 you can use a DataTable on it's own and hte
only reason to add a DataTable to a DataSet is if you want to work with
multiple tables at once and do stuff like create relationships etc.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,900
Latest member
Nell636132

Latest Threads

Top