C# CIMES中,动态添加where条件和模糊查询

 //也可以参考页面DNList.aspx.cs的第QueryData方法

       string strProduct = txtProduct.Text.Trim(); string strSql = "SELECT * FROM Table WHERE 1=1 "; List<object> paras = new List<object>(); if (!string.IsNullOrEmpty(strProduct)) { strSql += " AND product LIKE #[STRING]"; paras.Add("%" + strProduct + "%"); } DataTable dt = DBCenter.GetDataTable(strSql, paras.ToArray());

 

posted on 2024-11-21 15:17  写个笔记  阅读(19)  评论(0)    收藏  举报

导航