Sorry, I forgot to change the "s" and that you want an optimistic concurrency.
"UPDATE [DUSER] SET [username] = @username, [userpass] = @userpass WHERE [userid] = @userid And [username] = @original_username And [userpass] = @original_userpass" "DELETE FROM [DUSER] WHERE [userid] = @userid And [username] = @original_username And [userpass] = @original_userpass"
You, of course, will need to check if the row is updated / deleted.
Your InserCommand should also be: -
"INSERT INTO [DUSER] ([username], [userpass]) VALUES (@username, @userpass)"
Assuming that username and userpass are set so that they do not allow the NULL values that should be in this case, then Commands will fail if any parameter is null.
To avoid this, add <asp:RequiredFieldValidator>
for each userernameTextBox and userpassTextBox control to provide client-side validation.
You must also change the identifiers of the TextBox controls to match the parameter names.
If you need to deal with null values, you will need other parts of the generated queries, where will the null comparison begin, replacing? s to the corresponding parameter.
source share