rickb
Member
Heres what I have and what Id like to do:
A new User is added to a sql database via databound textboxes. The primary key is UserProfile field. I have Try/Catch set to Catch a SQLException when a duplicate UserProfile name is attempted to be entered. What I want to happen is give the user of the program a choice: Cancel the entire transaction (I have no problem here), or choose to attempt a different UserProfile, but preserving the changes so far and focus on the UserProfile.
I used an OKCancel button, and attempted to set the OK option to allow the program user to attempt a new UserProfile name. Heres my code for the messagebox in my Catch statement:
This doesnt work; clicking OK cancels the edit and resets all changes. Is there a way to just close the message box, set the focus, and allow the user to try again?
Thanks for any help.
A new User is added to a sql database via databound textboxes. The primary key is UserProfile field. I have Try/Catch set to Catch a SQLException when a duplicate UserProfile name is attempted to be entered. What I want to happen is give the user of the program a choice: Cancel the entire transaction (I have no problem here), or choose to attempt a different UserProfile, but preserving the changes so far and focus on the UserProfile.
I used an OKCancel button, and attempted to set the OK option to allow the program user to attempt a new UserProfile name. Heres my code for the messagebox in my Catch statement:
Code:
If MessageBox.Show("Duplicate UserProfile. Choose another name.", & _
"DUPLICATE USER PROFILE", MessageBoxButtons.OKCancel, " & _
"MessageBoxIcon.Error)=DialogResult.OK Then
txtUserProfile.focus()
End If
This doesnt work; clicking OK cancels the edit and resets all changes. Is there a way to just close the message box, set the focus, and allow the user to try again?
Thanks for any help.