private void UpdateWaitingList() { waitingList = new List <WaitingList>(); OleDbConnection cn = new OleDbConnection(); //Connection OleDbCommand cmd = new OleDbCommand(); //Command OleDbDataReader dr; String path = Assembly.GetExecutingAssembly().Location; path = path.Replace("bin\\Debug\\ICTProjectPOS.exe", "RestaurantDB.accdb"); String connectionString = String.Format("Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0}", path); cn.ConnectionString = @connectionString; cmd.Connection = cn; try { cmd.CommandText = "SELECT * FROM WaitingList"; cn.Open(); dr = cmd.ExecuteReader(); if (dr.HasRows) { while (dr.Read()) { WaitingList wl = new WaitingList(dr[0].ToString(), dr[1].ToString(), dr[2].ToString(), dr[6].ToString()); waitingList.Add(wl); } } cn.Close(); } catch { // empty } }
private void UpdateWaitingList() { waitingList = new List<WaitingList>(); OleDbConnection cn = new OleDbConnection(); //Connection OleDbCommand cmd = new OleDbCommand(); //Command OleDbDataReader dr; String path = Assembly.GetExecutingAssembly().Location; path = path.Replace("bin\\Debug\\ICTProjectPOS.exe", "RestaurantDB.accdb"); String connectionString = String.Format("Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0}", path); cn.ConnectionString = @connectionString; cmd.Connection = cn; try { cmd.CommandText = "SELECT * FROM WaitingList"; cn.Open(); dr = cmd.ExecuteReader(); if (dr.HasRows) { while (dr.Read()) { WaitingList wl = new WaitingList(dr[0].ToString(), dr[1].ToString(), dr[2].ToString(), dr[6].ToString()); waitingList.Add(wl); } } cn.Close(); } catch { // empty } }