表:员工
code|Name|Left
----+----+----
1 | A | Y
2 | B | N
3 | C | N
4 | D | Y
5 | E | N
6 | F | Y
现在我在做,
SqlConnection cn=new SqlConnection();
SqlCommand cmd = new SqlCommand();
cn.ConnectionString="<CONNECTION STRING>"
List<string> str = new List<string>();
cmd.Connection=cn;
cmd.Connection.Open();
cmd.CommandText="Select code from employee where Left='Y'";
SqlDataReader dr=cmd.executeReader();
while(dr.Read())
{
str.Add(dr1.GetValue(0).ToString());
}
foreach (string p in str)
{
Response.Write(p);
}
此代码仅获取1个数据,我如何获取Left ='Y'的所有数据
浮云间
相关分类