<job>
<script>
var oCat=new ActiveXObject('adox.catalog');
var oTbl=new ActiveXObject('adox.table');
oCat.Create("Provider=Microsoft.Jet.Oledb.4.0;Data Source=asfman.mdb");
/*
if asfman.mdb has already existed
connStr = "Provider=Microsoft.Jet.Oledb.4.0;Data Source=asfman.mdb";
oCat.ActiveConnection=connStr
*/
with(oTbl){
Name='iTable'; // table name
ParentCatalog=oCat;
Columns.Append('col1', 3); // integer
Columns.Append('col2', 7); // date
Columns.Append('col3', 205); // long binary
Columns.Append('col4', 203); // memo
Columns.Append('col5', 202); // text
Columns.Append('col6', 130); // text
Columns.Append('col7', 11); // boolean
Columns.Append('col8', 6); // currency
Columns.Append('col9', 72); // guid
/* 创建自动编号 */
Columns.Append('col10', 3); // integer
Columns('col10').Properties('AutoIncrement')=true;
}
oCat.Tables.Append(oTbl);
oTbl=null;
oCat=null;
</script>
</job>
//id自动增加类型
<job>
<script>
var catalog = new ActiveXObject("AdoX.Catalog");
catalog.Create("Provider=Microsoft.Jet.Oledb.4.0;Data Source=asfman.mdb");
var table = new ActiveXObject("AdoX.Table");
table.ParentCatalog = catalog;
table.Name = "test";
var col = new ActiveXObject("AdoX.Column");
col.Name="id";
col.Type = 3;
table.Columns.Append(col);
col.Properties('AutoIncrement')=true;
catalog.Tables.Append(table);
</script>
</job>
或者
<job>
<script>
var catalog = new ActiveXObject("AdoX.Catalog");
catalog.Create("Provider=Microsoft.Jet.Oledb.4.0;Data Source=asfman.mdb");
var table = new ActiveXObject("AdoX.Table");
//设置parentCatalog是关键
table.ParentCatalog = catalog;
table.Name = "test";
//var col = new ActiveXObject("AdoX.Column");
//col.Name="id";
//col.Type = 3;
table.Columns.Append("id",3,0);
table.Columns("id").Properties('AutoIncrement')=true;
catalog.Tables.Append(table);
</script>
</job>
posted on 2007-11-04 23:17
汪杰 阅读(716)
评论(2) 编辑 收藏 引用