i am working on a validation but it gives me an error that "operator && cannot be applied to bool"..
C#
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???

Vikas PanwarRank #1,447 · 1.1K reputationPosted Nov 12, 2021, 1:21 AM EST
Srinivasan RamamoorthiRank #877 · 2.5K reputationPosted Nov 12, 2021, 12:05 AM EST
Muhammad Anees13 reputationPosted Nov 12, 2021, 2:03 AM EST