Click here to Skip to main content
15,893,564 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
VB

Button for saving

VB
Dim objsmem As New BussinesLog.Login
        If TxtPosmem.Text = "Application_Admin" Then

            If TxtUser_mem.Text = objsmem.User_nameM And TxtPassmem.Text = objsmem.Passwords Then
                LitMessage.Text = ("This User_name or password already exists")

            ElseIf TxtUser_mem.Text <> objsmem.User_nameM And TxtPassmem.Text <> objsmem.Passwords Then
                objsmem.User_nameM = TxtUser_mem.Text
                objsmem.Function_id = 1
                objsmem.Passwords = TxtPassmem.Text
                objsmem.Question = DropDownList2.SelectedValue
                objsmem.Answer = TxtAnsmem.Text
                objsmem.Position = TxtPosmem.Text
                objsmem.Save_Mem_Account()
                MsgBox("Hope it works", MsgBoxStyle.Information, "SAVING>>>>>")
            End If

        End If
Posted

1 solution

Let the stored procedure handle it and return a value indicating that it's a duplicate userID (if it is). It really shouldn't matter if the password exists or not - just the user ID.
 
Share this answer
 
Comments
RaisKazi 31-Aug-11 10:37am    
Yes 5!. It's really doesn't logical to check Password exists or Not.
Only check on UserName should be enough.
Reiss 31-Aug-11 11:10am    
Agreed that the database should handle this - if this is the requirement then the userID column should have a unique constraint on it in the database, that way you can just try and insert the record and handle the error if it exists - this has the advantage of getting past any race conditions

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900