string sql = "select * from [Text] ";
if(Uid != "")
{
sql = sql + "where Uid= " + Uid + "";
}
它能放在连接的后面吗?
public void BindUserlIst(string Uid)是数据库里给的吗?
if(Uid != "")
{
sql = sql + "where Uid= " + Uid + "";
}
它能放在连接的后面吗?
public void BindUserlIst(string Uid)是数据库里给的吗?
sql += string.IsNullOrEmpty(Uid)?"":" and Uid= " + Uid + "";
public void BindUserlIst(string Uid)
{
string sql = "select * from [Text] ";
if(Uid != "")
{
sql = sql + "where Uid= " + Uid + "";
}
...
} 根据输入的查询条件查询数据? 什么是数据库里面给的?
string sql = "select * from [Text] where 1=1";
if(Uid != "")
{
sql = sql + "and Uid= " + Uid + "";
}
if( num!= "")
{
sql = sql + "and num= " + num+ "";
}
sql = sql + " and namelike '%'+@name+'%' ";
......
可以根据查询输入的条件拼接下去...
拼接后:select * from [Text] where 1=1 and Uid=1 and name like %name% and ...