string sql;
string sql2="where 1=1;
string key;
if(key!="")
{
sql2=sql2 +"and a.corp_name='"+key+"'";
}
sql="select a.* from corp '+sql2+"'";为什么这样不对。
string sql2="where 1=1;
string key;
if(key!="")
{
sql2=sql2 +"and a.corp_name='"+key+"'";
}
sql="select a.* from corp '+sql2+"'";为什么这样不对。
string sql2="where 1=1";
string key;
if(key!="")
{
sql2=sql2 +"and a.corp_name='"+key+"'";
}
sql="select a.* from corp "+sql2;
string sql2="where 1=1";
string key;
if(key!="")
{
sql2=sql2 +"and a.corp_name='"+key+"'";
}
sql="select a.* from corp a "+sql2;
还有
sql="select a.* from corp '+sql2+"'"; 在语句后面拼接sql不是这样写的。
应该是sql="select a.* from corp as a "+sql2;
还有啊,你前面写的 a.* 后面都没有a,你怎么查啊 corp as a,或者 corp a 不要as也可以就这样,一看楼主就是小鸟一个,好好努力,注重基础
using System.Text;string sql;
StringBuilder sb = new StringBuilder();
sb.Append("select * from corp where 1=1 ");
string key;
if(key!="")
{
sb.Append(" and corp_name='"+key+"' ");
}
sql=sb.ToString();
{
sql2=sql2 +"and a.corp_name='"+key+"'";
}
这个好像也是错的。
第一次能搜索到,第二次就修改不到了
string sql2="where 1=1";
string key;
if(key!="")
{
sql2=sql2 +"and a.corp_name='"+key+"'";
}
sql="select a.* from corp '"+sql2+"'";sql2干嘛用的?
答:"搜索用的"都是人才