C# 讀取 Access 資料

讀取Access 檔案資料 by Oledb

資料來源 : https://stackoverflow.com/questions/29460991/retrieve-image-to-a-picturebox-from-access-database

private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
{
   connection.Open();

   OleDbCommand command = new OleDbCommand();
   command.Connection = connection;
   string query = "select * from EmployeeInfo where FirstName = '" + listBox1.Text +"'";
   command.CommandText = query;
   OleDbDataReader reader = command.ExecuteReader();
   while (reader.Read()) 
   {
      list_fname.Text = reader["FirstName"].ToString();
      list_lname.Text = reader["LastName"].ToString();
      list_dob.Text = reader["DoB"].ToString();
   }
   connection.Close();
}