SqlParameter like
String searchName ="Sam"; String strSql = "select * FROM Table1 where Name like @Name "; searchName = "%"+searchName+"%"; //注意不用加单引号,传参到Sql语句中会自动添加 SqlParameter[] parameters = { new SqlParameter("@Name", searchName) };
String searchName ="Sam"; String strSql = "select * FROM Table1 where Name like @Name "; searchName = "%"+searchName+"%"; //注意不用加单引号,传参到Sql语句中会自动添加 SqlParameter[] parameters = { new SqlParameter("@Name", searchName) };