access数据库

   //访问动态创建access数据库 

                string conn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath("/Catering/") + ".accdb";



                //string conn = "Provider=Microsoft.Jet.Oledb.4.0;Data Source=F:/asp.net/MvcMovie/Access5;Jet OLEDB:Database Password=7958145;Jet OLEDB:Engine Type=5";

                ADOX.Catalog cata = new ADOX.Catalog();

                cata.Create(conn);

                ADODB.Connection cn = new ADODB.Connection();

                cn.Open(conn, null, null, -1);

                cata.ActiveConnection = cn;

                //

                ADOX.Table table = new ADOX.Table();

                table.Name = "ims_tbl_bClass";

                ADOX.Column column = new ADOX.Column();

                column.ParentCatalog = cata;

                column.Type = ADOX.DataTypeEnum.adInteger;

                column.Name = "bId";

                column.DefinedSize = 9;

                column.Properties["AutoIncrement"].Value = true;

                table.Columns.Append(column, ADOX.DataTypeEnum.adInteger, 0);

                table.Columns.Append("ClassbId", DataTypeEnum.adInteger, 0);

                table.Columns.Append("ClassbName", DataTypeEnum.adVarWChar, 51);

                table.Columns.Append("Gid", DataTypeEnum.adInteger, 0);

                table.Columns.Append("HotalId", DataTypeEnum.adInteger, 0);

 

 

你可能感兴趣的:(Access)