コード例 #1
0
        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();
        }
コード例 #2
0
        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);
            }
        }
コード例 #3
0
        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();
                }
            }
        }