关闭

分层架构的模糊查询问题笨方法

456人阅读 评论(0) 收藏 举报

 private const string SQL_SELECT_ALLLIST = "SELECT * FROM Counseling where uid=@UID";
 private const string PARM_UID = "@UID";
  public DataTable Search(Model.Counseling CSL)
        {
            SqlParameter[] SearchParms = new SqlParameter[1];
            SearchParms[0] = new SqlParameter(PARM_SEARCH, SqlDbType.VarChar,10);
            SearchParms[0].Value = CSL.search;
            if (CSL.searchKind == "CAuthor")
            {
                SQL_SELECT_SEARCH = SQL_SELECT_SEARCH + " AND Counseling.CAuthor like '%'+@SEARCH+'%'";
            }
            if (CSL.searchKind == "CContent")
            {
                SQL_SELECT_SEARCH = SQL_SELECT_SEARCH + " AND Counseling.CContent LIKE '%'+@SEARCH+'%'";
            }
            using (DataSet ds = SqlHelper.ExecuteDataset(SqlHelper.CONN_STRINGCSL, CommandType.Text, SQL_SELECT_SEARCH, SearchParms))
            {
                return ds.Tables[0];
            }
        }

 

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:48998次
    • 积分:911
    • 等级:
    • 排名:千里之外
    • 原创:32篇
    • 转载:19篇
    • 译文:0篇
    • 评论:11条