My page have textbox , lable and one button when the user click the button it should display message if the user in the database "email has been sent" the message will show otherwiser it will show "email is not in the system"
this is what I did , but the problem is that the last email in the database will get this massage and the firsts emails get the error message
protected void Button1_Click(object sender, EventArgs e)
{
string email = txtBoxEmail.Text.Trim();
lblMessage.Text = email;
string conString = ConfigurationManager.ConnectionStrings["StringConnection"].ConnectionString;
SqlCeConnection con = new SqlCeConnection(conString);
string sql = "Select * from accountInfo";
SqlCeCommand command = new SqlCeCommand(sql, con);
con.Open();
SqlCeDataReader dataReader = command.ExecuteReader();
while (dataReader.Read())
{
string emailAddress = dataReader["email"].ToString();
if (emailAddress.Equals(email))
{
lblMessage.Text = "Sent";
}
else
{
lblMessage.Text = "Invalid email";
}
}
con.Close();
}
I don't know what worng with the code