#Default.aspx.cs方法: ClassLibrary1.Help h = new ClassLibrary1.Help();
string sqlWhere = "1=1";
if (txttitle.Text != "")
{
sqlWhere += " and title like '%" + txttitle.Text + "%'";
}
if (txtlmmc.Text != "")
{
sqlWhere += " and lmmc = '" + txtlmmc.Text + "'";
} List
{
string sqlQuery = "select newid,title,lmmc,inputdatetime from V_Web_News";
if (Where != "")
{
sqlQuery += " where " + Where;
}
return dc.ExecuteQuery
}这是最简单的做法,查询。。。。Where语句是传过来的条件。拼接起来的。但是这种是最直接明了的。如果觉得简单你可以用麻烦点的。dc.V_Web_News.Where()这样写。不过有点小复杂。呵呵,你可以去网上看看。资料很多,我这个基本上能满足你的查询需求,因为SqlQuery这里面就是SQL语句。