Using system; using adox;
Summary description of Namespace Webportal {/// /// createaccessdb. /// For different versions of ADO, you need to add different references /// Please add a reference Microsoft Ado ext. 2.7 for DDL and security /// Please add a reference Microsoft Ado ext. 2.8 for DDL and security /// summary > Public class create createAccessdb: system.Web.ui.page {private void page_load (Object sender, system.eventargs e) {// For easy testing, the database name uses a relatively random name to prevent it from adding unsuccessful, it needs to be restarted. IIS to delete the database. String dbname = "d: // newmdb" DateTime.now.millisecond.toString () ".mdb"; adox.catalogclass cat = new adox.catalogclass (); cat.create ("provider = microsoft.jet.oledb .4.0; Data Source = " DBNAME "; "); response.write (" Database: " DBNAME " has created success! "); Adox.tableclass tbl = new adox.tableclass (); tbl.parentCatalog = Cat; tbl.name = "myTable";
// Add an automatic growth field adox.columnclass color (); col.parentCatalog = cat; col.Type = adox.DataTypeenum.adinteger; // must set the field type col.name = "id" Col.properties ["Jet OLEDB: Allow Zero Length"]. Value = false; col.properties ["autoincrement"]. Value = true; tbl.columns.Append (col, adox.dattypeenum.adinteger, 0);
// Add a text field 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.dattypeenum.advarchar, 25);
// Set the primary key tbl.keys.append ("PrimaryKey", Adox.Keytypeenum.adkeyPrimary, "ID", "", ""); Cat.Tables.Append (TBL); response.write ("
database table : " TBL.Name " has been created! "); Tbl = null; Cat = null;}
#Region Web Form Designer Generated Code Override Protected Void OnNit (Eventargs E) {// // Codegen: This call is required for the ASP.NET Web Form Designer. // InitializeComponent (); base.oninit (e);
/// /// Designer supports the required method - do not use the code editor to modify the // / this method. /// summary> private void initializecomponent () {this.load = new system.eventhandler (this.page_load);} #ENDREGON}}