Alright, I have this piece of code:
vb Code:
Assignments_SQLSelect() Adapter.DeleteCommand = New OleDbCommand("DELETE FROM Assignments WHERE CIndex = @CIndex") Adapter.DeleteCommand.Connection = Connection Connection.Open() With Adapter.DeleteCommand .Parameters.Add("@CIndex", OleDbType.Integer, 5, "CIndex") End With For Each DRow As DataRow In DS.Tables(0).Rows If DRow.Item("Student").ToString.Contains(.lstNames.Items.Item(.RIndex).Text) Then DRow = DS.Tables(0).Rows(.RIndex) DRow.Delete() End If Next Adapter.Update(DS) DS.AcceptChanges() Connection.Close()
So what its suppose to do is Loop Through each Row in the Database and then IF the DRow Contains the .RIndex.Text Item then it will Delete (This is Fine, I did a Debug to see if it was finding the items & doing the IF Statment (and it Did)
Problem: Its only deleting the First Row that Contains that Item, not the Rest. So.. how do I fix this? I tried putting Adapter.Update and DS.ACcept in the LOOP statement but came up with a ERROR.




Reply With Quote