VB working with SQL DB - end of row count, keeps looping
- by Tramd
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.