|
用asp.net动态创建的access表,如何设置其字段的“是否允许空字符串”、设置默认值???
谢谢!!
//创建access数据库
ADOX.Catalog cat =
new ADOX.Catalog();
cat.Create("Provider=Microsoft.Jet.OLEDB.4.0;Data Source="
+ Server.MapPath("~/") +
"mydb/"
+
this.txtDB.Text +
".mdb;Jet OLEDB:Engine Type=5");
//连接access数据库
ADODB.Connection conn =
new ADODB.Connection();
conn.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source="
+ Server.MapPath("~/") +
"mydb/"
+
this.txtDB.Text +
".mdb;Jet OLEDB:Engine Type=5", null, null, -1);
cat.ActiveConnection = conn;
ADOX.Table tb =
new ADOX.Table();
tb.Name =
"boss";
ADOX.ColumnClass column =
new ColumnClass();
column.ParentCatalog = cat;
column.Name =
"id";
column.Properties["AutoIncrement"].Value =
true;
tb.Columns.Append(column, ADOX.DataTypeEnum.adInteger, 4);
tb.Keys.Append("FirstTablePrimaryKey", ADOX.KeyTypeEnum.adKeyPrimary, column, null, null);
tb.Columns.Append("Name", ADOX.DataTypeEnum.adVarWChar, 50);
tb.Columns.Append("Pass", ADOX.DataTypeEnum.adVarWChar, 50);
ADOX.ColumnClass column1 =
new ADOX.ColumnClass();
column1.Name =
"loginLast";
column1.Properties["Jet OLEDB:Allow Zero Length"].Value =
false;
tb.Columns.Append(column1, ADOX.DataTypeEnum.adDBDate, 8);
ADOX.ColumnClass column2 =
new ADOX.ColumnClass();
column2.Name =
"indate";
column2.Properties["Default"].Value =
"Now()";
tb.Columns.Append(column2, ADOX.DataTypeEnum.adDate, 8);
cat.Tables.Append(tb);
conn.Close();
两块红色的地方怎么就有问题咧?我看过别人也是这么用的````````
|
|