我对下面的代码有一些问题。给我一个错误的是rdr = cmd.ExecuteReader();
,我不知道为什么。该代码假设检查 Items 表中是否有任何记录。任何帮助,将不胜感激。
protected void Page_Load(object sender, EventArgs e)
{
OleDbConnection mDB = new OleDbConnection();
mDB.ConnectionString = "Provider = Microsoft.Jet.OLEDB.4.0;Data source="
+ Server.MapPath("~/App_Data/Database.mdb");
OleDbCommand cmd;
OleDbDataReader rdr;
int intOrderNo = int.Parse(Session["sOrderNo"].ToString());
String strSql = "SELECT iProdID FROM Items WHERE iOrdersID = "+ intOrderNo;
cmd = new OleDbCommand(strSql, mDB);
mDB.Open();
rdr = cmd.ExecuteReader();
Boolean booRows = rdr.HasRows;
if (booRows)
{
ShoppingCartLabel.Text = "Your Shopping Cart";
if (Session["sFlag"] == "T")
{
BizCheckOutButton.Visible = true;
CusCheckOutButton.Visible = false;
}
else
{
BizCheckOutButton.Visible = false;
CusCheckOutButton.Visible = true;
}
}
else
{
ShoppingCartLabel.Text = "Your Shopping Cart is empty";
CusCheckOutButton.Visible = false;
BizCheckOutButton.Visible = false;
}
mDB.Close();
}