Error deleting datagrid row
I'm getting an error of There is no row at position 6. when I tried to delete row six from the datagrid. In fact, I tried all the rows in the datagrid and still receiving the same error message. Here's what tried before:
Quote:
Dim dgRowNumber As Integer = dgComputer.CurrentRowIndex
Try
DSetProgram.Program.Rows(dgRowNumber).Delete()
Catch exError As Exception
MessageBox.Show(exError.Message)
End Try
DAdptProgram.Update(DSetProgram.Tables("Program"))
DSetProgram.Tables("Program").AcceptChanges()
But still it gives me the error that there is no row at the position of the variable "dgRowNumber". So I tried this:
Quote:
dsUsrProfile.Tables("strTableName").Rows(dgRowNumber).Delete()
DAprofile.Update(dsUsrProfile.Tables("strTableName"))
dsUsrProfile.Tables("strTableName").AcceptChanges()
If (dsUsrProfile.HasChanges) Then
MsgBox("Changes has been committed")
End If
But the same error happened. However, I have a total of 6 rows in the table called "Program". In addition, when the program runs, the variable "dgRowNumber" do have an actual number that corresponds to the datagrid. If this variable would to contain some number that is not relating to the datagrid or out of the range then yes, I understand but it's not. It is within the range of the rows in the datagrid and database table.
ljCharlie