VB working with SQL DB - end of row count, keeps looping

Posted by Tramd on Stack Overflow See other posts from Stack Overflow or by Tramd
Published on 2010-04-21T00:42:03Z Indexed on 2010/04/21 0:43 UTC
Read the original article Hit count: 291

Filed under:
|
|

I'm adding to a combo box an ID and a name that i'm pulling from a database. My problem is that for some reason my loop doesnt end once it reaches the end of the records in the database table. Here's my code:

For intcount = 0 To dtOrders.Rows.Count - 1 cmbSearch.Items.Add(dtOrders.Rows(intcount)("EmployeeID").ToString & " " & dtOrders.Rows(intcount)("EmployeeLastName").ToString & ", " & dtOrders.Rows(intcount)("EmployeeFirstName").ToString) Next

Shouldnt the .rows.count - 1 stop it once it reaches the last record? It loops 4 times through.

© Stack Overflow or respective owner

Related posts about vb.net

Related posts about sql