473,383 Members | 1,821 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Loop through all fields in a single record?

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?

Apr 27 '06 #1
4 1200
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
}

"te***@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?

Apr 27 '06 #2
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

Apr 28 '06 #3
> 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)
Apr 28 '06 #4
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:
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)

Apr 28 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: !TG | last post by:
I currently use Do while loop, but I'd rather use a For Loop though I have never gotten the hang of them. Would some one please be so kind as to show me how to loop through a recordset.
20
by: Steve Jorgensen | last post by:
Hi all, I've just finished almost all of what has turned out to be a real bear of a project. It has to import data from a monthly spreadsheet export from another program, and convert that into...
8
by: Bill | last post by:
Hello out there; This may be a challenge but I'm certain it's possible but I can't seem to figure out how. I have a table that has several date fields, e.g., Date1, Date2, Date3, Date4 ......
4
by: Kathy | last post by:
Hi All, I am using Access 2000. I would like to streamline this code by using a variable for the column name. I have three tables with 255 columns each that I would like to populate with the...
52
by: MP | last post by:
Hi trying to begin to learn database using vb6, ado/adox, mdb format, sql (not using access...just mdb format via ado) i need to group the values of multiple fields - get their possible...
16
by: Jen | last post by:
Hi. I have this problem that I think should be easy but have been struggling with this for days. I have a list based on a recordset from a database. This list consists of records meeting a certain...
2
by: akanialaka | last post by:
Hope I can get some help here... I connect to an SQL database using ASP. I can see the records. I have a small (very basic) function written in Javascript. When I use the MoveNext in the...
24
by: oliv29 | last post by:
Hello, Can anyone tell me how do i fill a structure's fields in a for loop ? #define MAX_FIELD_LEN 10 typedef struct { char field1; /*will store first string read from keyboard*/
8
by: SaltyBoat | last post by:
Needing to import and parse data from a large PDF file into an Access 2002 table: I start by converted the PDF file to a html file. Then I read this html text file, line by line, into a table...
0
by: nbardach | last post by:
Hope this finds everyone well. Happy New Year! I'm trying to build a Loop for a set of dropdown menus I'm inserting into a form. Basically, the client has to be able to select 1 to 20 donors...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.