public DataTable Select(string sql, params object[] args)
{
IList<SqlParameter> parameters =
(args == null ? null : this.PopulateParametersWithSql(sql, args));//参数化处理 SqlCommand cmd = BuildCommand(sql, parameters); ds = new DataSet();
data = new SqlDataAdapter("", conn);
data.SelectCommand = cmd;
data.Fill(ds);
return ds.Tables[0];
}上面的方法中传入下面的列子 可以防止sql注入但 要怎么才能支持模糊查询呢?
string sql = "select Count(*) from MovieLst where [number] =@number";
DataTable table = sqlmdb.Select(sql, row.Cells["NumberColumn"].Value);
求一个防止sql注入 但也支持模糊查询的类 要有调用示例或是提供更好的思路(该贴无论是否有答案都会结贴给分)
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货