C#程序——多条件查询
string sql = "select * from Individual_Grade_Base where 1=1";
if(TextBox1.Text.Trim() != "")
{
sql = sql + " and name = '" +TextBox1.Text + "' ";
}
if(TextBox2.Text.Trim() != "")
{
sql = sql + " and name = '" +TextBox2.Text + "' ";
}
string sql = "select * from Individual_Grade_Base where 1=1";
if(TextBox1.Text.Trim() != "")
{
sql = sql + " and name = '" +TextBox1.Text + "' ";
}
if(TextBox2.Text.Trim() != "")
{
sql = sql + " and name = '" +TextBox2.Text + "' ";
}