查询是:
SELECT distinct( pro.id), pro.codigo,pro.descripcion
FROM producto pro where pro.codigo like @filtro
我在c#es参数化的代码:
public static DataSet GetDataSet(String SQL, String ruta, string filtro = "")
{
MySqlConnection conn = new MySqlConnection(getConnString(ruta));
MySqlDataAdapter da = new MySqlDataAdapter();
MySqlCommand cmd = conn.CreateCommand();
cmd.CommandText = SQL;
if (!filtro.Equals(""))
{
cmd.Parameters.AddWithValue("@filtro", "%" + filtro + "%");
}
da.SelectCommand = cmd;
DataSet ds = new DataSet();
conn.Open();
da.Fill(ds);
conn.Close();
return ds;
}
但在搜索中插入此代码:''%j%'); drop database namedb; /*'
并删除db
什么是SQL注入的解决方案?