Hi,
I have a question, a new user (Ali) want to register a form and he need to insert an email address. If Ali insert email address which is already exist in the database so the error message will given like above code. Then, Ali want to update his detail on the other update detail page and remain this original email address so, my qustion is how to allow Ali only to keep remain existing email but other new user cannot duplicate his email address. (*email address is a mandatory field).
else if (string.IsNullOrEmpty(txtEmail.Text.Trim()))
{
cvApplicantUpdate.ErrorMessage = "Please complete all compulsory fields (*) required";
txtEmail.Focus();
e.IsValid = false;
}
else if (txtEmail.Text.Trim() != "")
{
// check duplicate email ID
con.Open();
string apusername = txtEmail.Text;
string ap_username = txtEmail.Text;
String queryB = "SELECT ap_username FROM tbl_applicantsdetails WHERE ap_username = '" + apusername + "' ";
SqlCommand cmdB = new SqlCommand(queryB, con);
SqlDataReader drB = cmdB.ExecuteReader();
if (drB.Read())
{
// Message("Duplicate IC Number found.");
cvApplicantUpdate.ErrorMessage = "Email address already exists";
txtEmail.Focus();
e.IsValid = false;
drB.Close();
}
con.Close();
}
Kindly need some help. Thnak you.