Here is my code and when i fill all required fields it will not navigate to another page! what is the error and i want to check if email is already exist it will show error message Email already exists
protected void btnRegister_Click(object sender, EventArgs e)
{
SqlConnection myConnection = new SqlConnection(@"Data Source=ALIASHIQ\SQL2013;Initial Catalog=Person;Integrated Security=True");
SqlCommand cmd = new SqlCommand("INSERT INTO UserData(FirstName,LastName,Email,Mobile,Address,Password) VALUES (@Name,@LastName,@Email,@Mobile,@Address,@Password)", myConnection);
cmd.CommandType = CommandType.Text;
//if (txtEmail.Text == txtEmail.Text)
// {
cmd.Parameters.AddWithValue("@Name", txtName.Text);
cmd.Parameters.AddWithValue("@LastName", txtLastName.Text);
cmd.Parameters.AddWithValue("@Email", txtEmail.Text);
cmd.Parameters.AddWithValue("@Mobile", txtMobile.Text);
cmd.Parameters.AddWithValue("@Address", txtAddress.Text);
cmd.Parameters.AddWithValue("@Password", txtPassword.Text);
// cmd.Parameters.AddWithValue("@Password", txtPassword.Text);
myConnection.Open();
cmd.ExecuteNonQuery();
myConnection.Close();
Response.Redirect("contenctwelcome.aspx");
//}
//else
//{
// ErrorMessage.Text = "Please enter all fields";
//}