Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //EXTRACTION DES PRODUITS LIST
- private List<Product> RetrieveProducts()
- {
- //Connection
- bool connected = false;
- string accessConnectionString = string.Format("Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};Jet OLEDB:Database Password={1};", textBoxAccessPath.Text, textBoxAccessPassword.Text);
- OleDbConnection con;
- con = new OleDbConnection(accessConnectionString);
- if (con.State != ConnectionState.Open)
- {
- try
- {
- con.Open();
- connected = true;
- }
- catch (Exception exception)
- {
- }
- }
- //Retrive Data to create a temp array of current database
- List<Product> productList = new List<Product>();
- OleDbCommand custCMD = new OleDbCommand("SELECT * FROM Prod", con);
- OleDbDataReader custReader = custCMD.ExecuteReader();
- while (custReader.Read())
- {
- //Retrive Data to create a temp array of current database
- productList.Add(
- new Product()
- {
- ProductUPC = custReader["ProdNumUPC"].ToString(),
- ProductName = custReader["PName"].ToString(),
- Price = custReader["PPrice2"].ToString(),
- Dispo = custReader["Addi4"].ToString()
- }
- );
- Application.DoEvents();
- }
- return productList;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement