Hi
How to make connection to Ms-Access Database & export to excel in windows form application
Thanks
Hi
How to make connection to Ms-Access Database & export to excel in windows form application
Thanks
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Amit MohantyRank #112 · 20K reputationPosted Dec 5, 2022, 12:31 AM EST
Try this
string connectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=mdbFilePath\yourDb.mdb"; string sqlQuery = "SELECT * FROM yourTable"; using (OleDbConnection connection = new OleDbConnection(connectionString)) { OleDbCommand command = new OleDbCommand(sqlQuery, connection); try { connection.Open(); OleDbDataAdapter oleDbDataAdapter = new OleDbDataAdapter(command); oleDbDataAdapter.Fill(dataTable); } catch (Exception ex) { MessageBox.Show(ex.Message); } } dataGridView1.DataSource = dataTable;For export to excel check below link
https://www.c-sharpcorner.com/blogs/export-datagridview-data-to-excel-in-c-sharp
Aravind GovindarajRank #430 · 5.8K reputationPosted Dec 5, 2022, 4:23 AM EST
On top of Amit, you have a few more options if you want to go, please look into NuGet Gallery | NetOffice.Access 1.7.4.11