public form_ExternalDB(string selCategory, string extDB, DataGridView dataGridView) { selectedCategory = selCategory; extDBPath = extDB; extDataGridView = dataGridView; oAccess = new Microsoft.Office.Interop.Access.Application(); oAccess.OpenCurrentDatabase(extDBPath); daoDB = oAccess.CurrentDb(); oAccess.Visible = false; InitializeComponent(); }
static void Main(string[] args) { var accApp = new Microsoft.Office.Interop.Access.Application(); accApp.OpenCurrentDatabase(new FileInfo("db.accdb").FullName); Microsoft.Office.Interop.Access.Dao.Database cdb = accApp.CurrentDb(); foreach (TableDef item in cdb.TableDefs) { Console.WriteLine(item.Name); } }
public void CloseDatabase() { if (null != oAccess.CurrentDb()) { oAccess.CloseCurrentDatabase(); oAccess.Quit(); System.Runtime.InteropServices.Marshal.ReleaseComObject(oAccess); GC.Collect(); foreach (Process pr in Process.GetProcessesByName("MSACCESS")) { pr.Kill(); } } }