2
Answers

Password match problem

Vandana Sardana

Vandana Sardana

15y
3.2k
1
I am developing a windows application, my database is in MS-Access, i have the user details form which will store all the users detail as well as create the username and the password for login to the application. It is working all right but i have used 2 textboxes, 1 for password and the other one for confirmpassword. I want that the password and the confirmpassword should be same. But it is not happening. Now the user can feed 2 passwords. But actually this should not happen. Please help me out how to do it. The coding for the user details form is: private void btnadd_Click(object sender, EventArgs e) { pageAction = "ADD"; ClearFields(); SetEditState(true); txtusrname.Focus(); } private void btnsave_Click(object sender, EventArgs e) { try { ConnectionClass l_ConnectionClass = new ConnectionClass(); userId = l_ConnectionClass.generateIDnew("select max(userId) from [tbluserlogin]"); userName = txtusrname.Text.ToString(); userPwd = txtpwd.Text; userConPwd = txtconfirmpwd.Text; string logouttime = DateTime.MinValue.ToString(); users = l_ConnectionClass.checkuser(userName); if (users > 0) { MessageBox.Show("username already exists."); } else { l_ConnectionClass.SaveAddUser(userId, userName, userStatus, userRole, userPwd, userConPwd, logouttime); LoadGrid(); ClearFields(); txtusrname.Focus(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } } private void btndelete_Click(object sender, EventArgs e) { try { ConnectionClass l_ConnectionClass = new ConnectionClass(); if (MessageBox.Show("You want to delete it.", "User Details", MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.OK) { l_ConnectionClass.DeleteAddUser(userId); ClearFields(); LoadGrid(); } else { return; } } catch (Exception ex) { MessageBox.Show(ex.Message); } } private void btncancel_Click(object sender, EventArgs e) { LoadGrid(); SetEditState(false); } private void btnclose_Click(object sender, EventArgs e) { this.Close(); } private void dgvuserlogin_SelectionChanged(object sender, EventArgs e) { try { if (dgvuserlogin.SelectedRows.Count > 0) { userId = Convert.ToInt32(dgvuserlogin.CurrentRow.Cells["userId"].Value); PublicVariables.OSUserID = Convert.ToInt32(dgvuserlogin.CurrentRow.Cells["userId"].Value); userName = Convert.ToString(dgvuserlogin.CurrentRow.Cells["userName"].Value); userStatus = Convert.ToInt32(dgvuserlogin.CurrentRow.Cells["userStatus"].Value); string _userRole = dgvuserlogin.CurrentRow.Cells["userRole"].Value.ToString(); if (_userRole == "Admin") { rbtnadmin.Checked = true; } else { rbtnadmin.Checked = false; } if (_userRole == "Normal") { rbtnnormal.Checked = true; } else { rbtnnormal.Checked = false; } if (_userRole == "Display") { rbtndisplay.Checked = true; } else { rbtndisplay.Checked = false; } userPwd = Convert.ToString(dgvuserlogin.CurrentRow.Cells["userPwd"].Value); userConPwd = Convert.ToString(dgvuserlogin.CurrentRow.Cells["userConPwd"].Value); } } catch (Exception ex) { MessageBox.Show(ex.Message); } } Please help with the changes in the coding
Answers (2)