我正在使用数据阅读器将特定列数据显示到网格视图中。实际上我想从表中获取最后一天的记录。
DateTime yestarday = DateTime.Today.AddDays(-1);
string query = "select NAME,CLOSING_READING,RATE from CASHSALE_DETAIL where DATE = '" + yestarday + "'";
SqlCommand cmd = new SqlCommand();
cmd.Connection = Conn;
cmd.CommandText = query;
SqlDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
CashSaleVoucherGridView.Rows.Add(num, "", dr["NAME"].ToString(), dr["CLOSING_READING"].ToString(), "", "", "", dr["RATE"].ToString());
num++;
}
在上面给定的查询数据阅读器返回我 0 记录。有什么建议吗???