One problem is that the error message "Username already exists." is shown regardless of what error you really get. For example, if you get a datatype conversion error, you show "Username already exists."
Check the value of "err" when the exception is thrown and please post the exact error message.
"The changes you requested to the table were not successful because they would create duplicate values in the index, primary key, or relationship. Change the data in the field or fields that contain duplicate data, remove the index, or redefine the index to permit duplicate entries and try again."
Ok, after the failure, are you rejecting changes to the datatable to remove the row that had the duplicate data? If not, that row will still exist and each time you click save, it will still try to add that new row.
Something like this:
Or, do you completely scrap the dataset and reload it after the failure to contain the latest data, without the new row?
For Each ctrl As Control In Me.Controls("pnlMainPanel").Controls
If ctrl.GetType Is GetType(System.Windows.Forms.Panel) Then
For Each subCtrl As Control In ctrl.Controls
If subCtrl.GetType Is GetType(System.Windows.Forms.TextBox) Then
If subCtrl.GetType Is ...