Problem with DataTable and foreach

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
 
G

Guest

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?
 

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

Top