我试图从订单表中显示最近的“订单”。但是,即使我在表中有一些订单,我也会收到“没有订单要获取”的消息。代码有什么问题?
public static List<OrderInfo> GetOrdersByRecent (int count)
{
DbCommand comm = GenericDataAccess.CreateCommand ();
comm.CommandText = "OrdersGetByRecent";
DbParameter param = comm.CreateParameter ();
param.ParameterName = "@Count";
param.Value = count;
param.DbType = DbType.Int32;
comm.Parameters.Add (param);
return ConvertDataTableToOrders (GenericDataAccess.ExecuteSelectCommand (comm));
}
protected void byRecentGo_Click(object sender, EventArgs e)
{
try
{
int recordCount = Int32.Parse(recentCountTextBox.Text);
List<OrderInfo> orders = CommerceLibAccess.GetOrdersByRecent(recordCount);
grid.DataSource = orders;
if (orders.Count == 0)
{
errorLabel.Text = "<br />No orders to get.";
}
}
catch
{
errorLabel.Text = "<br />Couldn't get the requested orders!";
}
finally
{
grid.DataBind();
}
}