摘要:
public string GetPageNum(int curpage, int pagesize, int totalSize) { int allpage = pagesize; int next = 1; int pre = 1; int startcount = 0; int endcount = 0; pagestr = ""; if (curpage 1) { curpage = 1; } if (curpage = 1) { next = curpage + 1; } if (curpage 1) { pre = curpage - 1; } startcount = 阅读全文
摘要:
按常规的思路,我们会这样写 复制代码 代码如下:String searchName ="Sam"; String strSql = "select * FROM Table1 where Name like '%@Name%' "; SqlParameter[] parameters = { new SqlParameter("@Name", searchName) }; 但结果是查询不到结果,跟踪代码也没有发现错误,又不想用字符串拼接的方式(防止攻击)。于是跟踪了Sql的执行,发现问题在于Sql给参数自动添加了单引号。实际上在Sql,将like的代码解析成为了 like '%'Sam'%' 阅读全文