Problem with DataTable and foreach

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi
i am selecting a table from a db and assign it via DataAdapter to a DataTable.
I now want to do an action for each ro in the DataTable, for what i choose
foreach to accomplish that. My Problem ist now, that the row count shows me
that there are 5 rows in the DataTable, same as in db, but the action is done
only 4 times. The last row in the DataTable seems to be ignored.

Here the place in the code is use:

//Create Data-Table
DataTable dt = new DataTable();
MySqlDataAdapter da = new MySqlDataAdapter("SELECT * FROM qmgrs", conn );
MySqlCommandBuilder cb = new MySqlCommandBuilder(da);

//Fill Table with QueueManager data
da.Fill(dt);

foreach (DataRow dr in dt.Rows){
try {

Are there any ideas for this problem??

Thanks, Thorsten
 
Thorsten,

what is the rest of the code after your try statement? is there anything in
there failing that's causing the application to skip whatever action your
trying to do and go straight to the catch exception?
 
Back
Top