Muhammad Anees

Muhammad Anees

  • NA
  • 15
  • 946

Hello! I am working on a login form and creating a validation.

Nov 12 2021 2:06 AM

i am working on a validation but it gives me an error that "operator && cannot be applied to bool".. 

if (txt_Name.Text != "" && txt_State.Text != "") {  
    cmd = new SqlCommand("insert into tbl_Record(Name,State) values(@name,@state)", con);  
    con.Open();  
    cmd.Parameters.AddWithValue("@name", txt_Name.Text);  
    cmd.Parameters.AddWithValue("@state", txt_State.Text);  
    cmd.ExecuteNonQuery();  
    con.Close();  
    MessageBox.Show("Record Inserted Successfully");  
    DisplayData();  
    ClearData();  
} else {  
    MessageBox.Show("Please Provide Details!"); 
}

Please guide me how to fix it???


Answers (3)