以下のコードはres.aspx.cs
、このコード行がエラーを引き起こしているフィールドから何も読み取ることができませんでした:
strStatus = rdr["rStatus"].ToString();
protected void Page_Load(object sender, EventArgs e)
{
OleDbConnection mDB = new OleDbConnection();
mDB.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data source="
+ Server.MapPath("~/App_Data/Database.accdb");
OleDbCommand cmd; OleDbDataReader rdr;
string strUserId = (string)Session["sUserId"];
string strStatus;
string strSql = "SELECT rStatus FROM Reservation WHERE rUserId =" + strUserId
+ " ORDER BY rStatus DESC;";
cmd = new OleDbCommand(strSql, mDB);
cmd.Parameters.Add("@UserId", OleDbType.Char).Value = strUserId;
mDB.Open();
rdr = cmd.ExecuteReader();
strStatus = rdr["rStatus"].ToString();
while (rdr.Read() == true)
// string strRStatus = (string)Session["srStatus"];
// while (rdr.Read() == true)
if (strStatus == "-1")
{
DetailsView1.Visible = false;
Label2.Visible = false;
btnBuy.Visible = false;
DropDownList1.Visible = false;
btnCancel.Visible = false;
lblReserve.Text = "There is no resevation for user " + Session["sUserId"];
}
else
{
lblReserve.Visible = false;
Label1.Visible = true;
Label2.Visible = true;
DetailsView1.Visible = true;
btnBuy.Visible = true;
DropDownList1.Visible = true;
btnCancel.Visible = true;
}
}