各位大侠好:
问一个问题,郁闷很久,有一个表(A)是主表,其他3个表(B,C,D)是从表。
要求:从主表当中选择记录
string mysql = "";
if (DDLtype.SelectedItem.Text == "条件1")//如果值为“条件1”
{
mysql = "select * from A";
if (Chball.Checked == true)
{
mysql += "";
}
else
{
if (DDLtiaojian.SelectedItem.Text == "地址")
mysql = mysql + "where 地址 LIKE '%" + Txtneirong.Text + "%'";
if (DDLtiaojian.SelectedItem.Text == "姓名")
mysql = mysql + "where 姓名 LIKE '%" + Txtneirong.Text + "%'";
}
}
但是,在运行时,总是提示like附近有错误,请问是和主表,从表有关系吗?
问一个问题,郁闷很久,有一个表(A)是主表,其他3个表(B,C,D)是从表。
要求:从主表当中选择记录
string mysql = "";
if (DDLtype.SelectedItem.Text == "条件1")//如果值为“条件1”
{
mysql = "select * from A";
if (Chball.Checked == true)
{
mysql += "";
}
else
{
if (DDLtiaojian.SelectedItem.Text == "地址")
mysql = mysql + "where 地址 LIKE '%" + Txtneirong.Text + "%'";
if (DDLtiaojian.SelectedItem.Text == "姓名")
mysql = mysql + "where 姓名 LIKE '%" + Txtneirong.Text + "%'";
}
}
但是,在运行时,总是提示like附近有错误,请问是和主表,从表有关系吗?
if (DDLtype.SelectedItem.Text == "条件1")//如果值为“条件1”
{
mysql = "select * from A";
if (Chball.Checked == true)
{
mysql += "";
}
else
{
if (DDLtiaojian.SelectedItem.Text == "地址")
mysql = mysql + "where 地址 LIKE '%'"+" Txtneirong.Text +"'%'";
if (DDLtiaojian.SelectedItem.Text == "姓名")
mysql = mysql + "where 姓名 LIKE '%'"+Txtneirong.Text+"'%'";
}
}
else
{
mysql += " where "+DDLtiaojian.SelectedItem.Text +" LIKE '%" + Txtneirong.Text + "%'"; }