string sqlstr="select * from table where filename like "%@field%";
using (SqlConnection conn=new SqlConnection("……"))
{
SqlCommand cmd=new SqlCommand(sqlstr,conn);
cmd.Parameter.Add(new SqlParameter("@field",你的变量的值);
cmd.CommandType=CommandType.Text;//重要
conn.Open();
SqlDataReader dr=cmd.ExcuteReader();
if (dr.Read())
{
……
}
}