Esempio n. 1
0
        private void btnJetAccess_Click(object sender, EventArgs e)
        {
            string fileNoPass = Path.Combine(Path.GetTempPath(), "EmptyNoPass.mdb");
            string filePass   = Path.Combine(Path.GetTempPath(), "EmptyWithPass.mdb");

            //创建不带密码的空数据库
            JetAccessUtil.CreateMDB(fileNoPass);
            //创建带密码的空数据库
            JetAccessUtil.CreateMDB(filePass, "*****@*****.**");

            //压缩不带密码的数据库
            JetAccessUtil.CompactMDB(fileNoPass);
            //压缩带密码的数据库
            JetAccessUtil.CompactMDB(filePass, "*****@*****.**");

            // 停顿一秒
            //Thread.Sleep(1000);

            //重新设置数据库的密码
            //JetAccessUtil.SetMDBPassword(filePass, "*****@*****.**", "6966254");
            //列出数据库的表名称
            List <string> tableNameList = JetAccessUtil.ListTables(filePass, "*****@*****.**");
            string        strNameList   = "";

            foreach (string name in tableNameList)
            {
                strNameList += string.Format(",{0}", name);
            }
            if (!string.IsNullOrEmpty(strNameList))
            {
                MessageDxUtil.ShowTips(strNameList);
            }

            //Process.Start(Path.GetTempPath());
        }
Esempio n. 2
0
        private void btnOleDbHelper_Click(object sender, EventArgs e)
        {
            string        access        = @"DB\WinFramework.mdb";
            List <string> tableNameList = JetAccessUtil.ListTables(access, "");
            OleDbHelper   helper        = new OleDbHelper(access);

            foreach (string tableName in tableNameList)
            {
                string  sql = string.Format("Select * from {0} ", tableName);
                DataSet ds  = helper.ExecuteDataSet(sql);
                if (ds.Tables[0].Rows.Count > 0)
                {
                    MessageDxUtil.ShowTips(string.Format("tableName:{0} RowCount:{1}", tableName, ds.Tables[0].Rows.Count));
                }
            }
        }