这是我的代码,我已将此功能放在我的案例中,为什么我仍然无法从MS Access数据库中检索任何数据?是数据库问题吗?或者因为我的MS Access是版本2013,这是一个盗版版本?
public void display(event_detail e)
{
string path = Directory.GetCurrentDirectory();
string connstring = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + path + @"\GameMuseumManagementSystem.mdb";
OleDbConnection conn = new OleDbConnection(connstring); //Create connection
conn.Open();
OleDbCommand cmd = new OleDbCommand("SELECT * from Event WHERE Event_Title ='" + PassName + "'", conn); //Create command
cmd.Connection = conn; //command connect to database
OleDbDataReader myReader = cmd.ExecuteReader();
while (myReader.Read())
{
e.notxt.Text = (myReader["Event_No"].ToString());
//e.notxt.ReadOnly = true;
e.titletxt.Text = (myReader["Event_Name"].ToString());
//e.titletxt.ReadOnly = true;
e.datedetail.Text = (myReader["Event_Date"].ToString());
//e.datedetail.ReadOnly = true;
e.detailtxt.Text = (myReader["Event_detail"].ToString());
//e.detailtxt.ReadOnly = true;
}
}