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?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
}
"tedqn@.yahoo.com" wrote:
> 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?
>
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
> 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)
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.
"G?ran Andersson" wrote:
> Declare a reference to a DataTable and make it reference the table you
> want to use:
> DataTable table
> table = dsXXX.tables(0)
>
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment