Ejemplo n.º 1
0
        private void btnCreateMDB_Click(object sender, EventArgs e)
        {
            System.Windows.Forms.SaveFileDialog sfd = new SaveFileDialog();
            sfd.DefaultExt = "mdb";
            sfd.Filter     = "Access 数据库文件(*.mdb)|*.mdb|所有文件|*.*";
            sfd.Title      = "设置 Access 数据库的文件名";
            sfd.FileName   = this.m_Db.FileName;

            if (sfd.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    AccessDb _AccessDb = AccessDb.CreateDbInstance(sfd.FileName);
                    this.txtFileName.Text = _AccessDb.FileName;

                    MessageBox.Show("数据库已创建。", "Access 数据库", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Access 数据库", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }