嗨,我有一个问题,就像学期和学校一样搜索2个值,它只给我一条记录,而我找到了至少30条记录。
string conn = ConfigurationManager.ConnectionStrings["MyDatabase"].ConnectionString;
using (SqlConnection sqlcon = new SqlConnection(conn))
{
using (SqlCommand cmd = new SqlCommand())
{
cmd.CommandText = "SELECT *FROM tblEvaluation WHERE Semester LIKE '%' + @sem + '%' and SchoolYear like '%' + @sy + '%'";
cmd.Connection = sqlcon;
cmd.Parameters.AddWithValue("@sem", DropDownList1.Text);
cmd.Parameters.AddWithValue("@sy", DropDownList2.Text);
DataTable dt = new DataTable();
using (SqlDataAdapter sda = new SqlDataAdapter(cmd))
{
sda.Fill(dt);
GridView1.DataSource = dt;
GridView1.DataBind();
}
}
}