private void textBox8_Validated(object sender, EventArgs e)
{
SqlCommand cmd = new SqlCommand("SELECT model,fram_no,status FROM add_stock WHERE engen_no='" + textBox8.Text + "'", my);
my.Open();
SqlDataReader dr = cmd.ExecuteReader();
dr.Read();
if (dr.HasRows)
{
if (dr["status"].ToString() == "Sold")
{
MessageBox.Show("This Bike Is Sold");
textBox8.Text = "";
}
if (dr["status"].ToString() == "Available")
{
textBox16.Text = dr["model"].ToString();
textBox9.Text = dr["fram_no"].ToString();
}
}
else
{ MessageBox.Show("NOT A VALID ENGINE NO");
textBox8.Text = "";}
my.Close();
}
no error in code when i enter invalid no error messag shown bt when enter correct one no messag is diplayed for sold and not woks available code wahts wrong