using (Conn = new SqlConnection(ConnectionString))
{ Conn.Open();//打开数据库连接 string sqlstr = "select * from UserInfo2"; SqlCommand cmd = new SqlCommand(sqlstr, Conn); cmd.CommandType = CommandType.Text; SqlDataReader dr = cmd.ExecuteReader(CommandBehavior.CloseConnection);//创建 SqlDataReader实例 Response.Write("会员名称如下:<br/>"); while (dr.Read())//遍历数据 { Response.Write(dr["UserName"] + "<br/>"); } }