Tag: executereader

C#关闭阅读器时无效尝试调用Read

当我在C#语言中进行3层项目时,我无法尝试在读取器关闭时调用Read错误。 我想要做的是通过将两个表连接在一起并在下拉列表中显示来检索地址数据列。 这是我的数据访问层: public List getDistributionAll() { List distributionAll = new List(); string address; SqlDataReader dr = FoodBankDB.executeReader(“SELECT b.addressLineOne FROM dbo.Beneficiaries b INNER JOIN dbo.Distributions d ON d.beneficiary = b.id”); while (dr.Read()) { address = dr[“addressLineOne”].ToString(); distributionAll.Add(new Distribution(address)); } return distributionAll; } 这是我的FoodBankDB类: public class FoodBankDB { public static string connectionString = Properties.Settings.Default.connectionString; public static […]