Ester <anonymous@discussions.microsoft.com> wrote:[color=blue]
> I would like to read data from a database table row by row and
> execute some codes based on the data retrieved from each row. For
> example, there are 4 fields on a table called Image_Tbl. Those fields
> are Image ID, Image Path Name, X-Coordinate, and Y-Coordinate. Data
> stored on the table will be:
>
> Image ID Image Path Name X-Coordinate Y-Coordinate
> ImgBtnLight image\light.gif 192px 92px
> ImgBtnAC image\ac.gif 256px 152px
>
> How should I make a loop saying before end of the database table
> records and for each row of data, execute the some codes. Thank you
> for your time.[/color]
Assuming you've already loaded the table into a DataTable (eg using
DataAdapter.Fill)...
In C#:
foreach (DataRow row in table.Rows)
{
// Do something with row
}
In VB.NET:
Dim row as DataRow
For Each row in table.Rows
' Do something with row
Next
--
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too