public SqlDataReader GetCategories() { string connectionString = ConfigurationManager.ConnectionStrings["SQLConnString"].ConnectionString; SqlConnection conn = new SqlConnection(connectionString); conn.Open();
string cmdString = "SELECT Name FROM Category"; SqlCommand cmd = new SqlCommand(cmdString, conn); SqlDataReader rdr = cmd.ExecuteReader();
//这个怎么办呢?不加,不规范;加呢?阅读器关闭时 FieldCount 的尝试无效。 conn.Close();
return rdr; }