I am trying to select specific persons with their ID by using ASP.NET Gridview, but only the last userID reads. Let's say I have ID's 3, 4, and 6, and only ID number 6 does not appear in the Gridview table but 3 and 4 appear. They
should not appear even 3 and 4 because I am running the sql script as:
WHERE NOT EmployeeId = " + userID
.
foreach (int userID in userIDList)
{
string cs = ConfigurationManager.ConnectionStrings["MYDB"].ConnectionString;
using (SqlConnection con = new SqlConnection(cs))
{
SqlCommand cmd = new SqlCommand("SELECT FirstName, LastName FROM Employee WHERE NOT EmployeeId = " + userID, con);
con.Open();
GridView4.DataSource = cmd.ExecuteReader();
GridView4.DataBind();
}
}