string sqlStr="select * from [TABLE] where";
if(textbox1.text.trim()!="")
{
sqlStr += "field = '"+textbox1.text.trim()+"' And "
}
if(textbox2.text.trim()!="")
{
sqlStr += "field = '"+textbox2.text.trim()+"' And "
}
sqlStr=sqlStr.Substring(0,sqlStr.Length-5);