由于在程序中使用了ADOX,所以先要在解决方案中引用之,方法如下:
解决方案资源管理器-->引用-->(右键)添加引用-->COM-->Microsoft ADO Ext. 2.8 for DDL and Security

private void btnCreate_Click(object sender, EventArgs e)
        {
            string dbName = "E:\\Temp\\" + DateTime.Now.Millisecond.ToString() + ".mdb";
            ADOX.CatalogClass cat = new ADOX.CatalogClass();
            cat.Create("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + dbName + ";");
            MessageBox.Show("数据库:" + dbName + "已经创建成功!");

            //新建一个表
            ADOX.TableClass tbl = new ADOX.TableClass();
            tbl.ParentCatalog = cat;
            tbl.Name = "MyTable";

            //增加一个自动增长的字段
            ADOX.ColumnClass col = new ADOX.ColumnClass();
            col.ParentCatalog = cat;
            col.Type = ADOX.DataTypeEnum.adInteger; // 必须先设置字段类型
            col.Name = "id";
            col.Properties["Jet OLEDB:Allow Zero Length"].Value = false;
            col.Properties["AutoIncrement"].Value = true;
            tbl.Columns.Append(col, ADOX.DataTypeEnum.adInteger, 0);

            //增加一个文本字段
            ADOX.ColumnClass col2 = new ADOX.ColumnClass();
            col2.ParentCatalog = cat;
            col2.Name = "Description";
            col2.Properties["Jet OLEDB:Allow Zero Length"].Value = false;
            tbl.Columns.Append(col2, ADOX.DataTypeEnum.adVarChar, 25);
            cat.Tables.Append(tbl);   //这句把表加入数据库(非常重要)
            MessageBox.Show("数据库表:" + tbl.Name + "已经创建成功!");
            tbl = null;
            cat = null;

        }