热卖商品
新闻详情
ADOX创建ACCESS数据库列名的数据类型-sunnybay-ChinaUnix博客
来自 : blog.chinaunix.net/uid-9847882
发布时间:2021-03-25
usingSystem;
usingSystem.Collections.Generic;
usingSystem.Text;
usingADOX;
namespaceADOXCreateTable
{
classProgram
{
staticvoidMain(string[]args)
{
stringdbName=\"D:DataBaseFirstCatalog.mdb\";
ADOX.CatalogClasscatlog=newADOX.CatalogClass();
catlog.Create(\"Provider=Microsoft.Jet.OLEDB.4.0;DataSource=\"+dbName+\";\"+\"JetOLEDB:EngineType=5\");
ADOX.TableClasstable=newADOX.TableClass();
table.ParentCatalog=catlog;
table.Name=\"FirstTable\";
//StuIdColumn(AutoIncrement)
ADOX.ColumnClasscol1=newADOX.ColumnClass();
col1.ParentCatalog=catlog;
col1.Type=ADOX.DataTypeEnum.adInteger;
col1.Name=\"StuId\";
col1.Properties[\"JetOLEDB:AllowZeroLength\"].Value=false;
col1.Properties[\"AutoIncrement\"].Value=true;
//NameColumn
ADOX.ColumnClasscol2=newADOX.ColumnClass();
col2.ParentCatalog=catlog;
col2.Name=\"StuName\";
col2.Properties[\"JetOLEDB:AllowZeroLength\"].Value=false;
//AgeColumn
ADOX.ColumnClasscol3=newADOX.ColumnClass();
col3.ParentCatalog=catlog;
col3.Name=\"Stuage\";
col3.Type=DataTypeEnum.adDouble;
col3.Properties[\"JetOLEDB:AllowZeroLength\"].Value=false;
//Primary
table.Keys.Append(\"PrimaryKey\",ADOX.KeyTypeEnum.adKeyPrimary,\"StuId\",\"\",\"\");
table.Columns.Append(col1,ADOX.DataTypeEnum.adInteger,0);
table.Columns.Append(col3,ADOX.DataTypeEnum.adDouble,666);
table.Columns.Append(col2,ADOX.DataTypeEnum.adVarChar,25);
catlog.Tables.Append(table);
System.Runtime.InteropServices.Marshal.ReleaseComObject(table);
System.Runtime.InteropServices.Marshal.ReleaseComObject(catlog);
table=null;
catlog=null;
GC.WaitForPendingFinalizers();
GC.Collect();
}
}
}
usingSystem.Collections.Generic;
usingSystem.Text;
usingADOX;
namespaceADOXCreateTable
{
classProgram
{
staticvoidMain(string[]args)
{
stringdbName=\"D:DataBaseFirstCatalog.mdb\";
ADOX.CatalogClasscatlog=newADOX.CatalogClass();
catlog.Create(\"Provider=Microsoft.Jet.OLEDB.4.0;DataSource=\"+dbName+\";\"+\"JetOLEDB:EngineType=5\");
ADOX.TableClasstable=newADOX.TableClass();
table.ParentCatalog=catlog;
table.Name=\"FirstTable\";
//StuIdColumn(AutoIncrement)
ADOX.ColumnClasscol1=newADOX.ColumnClass();
col1.ParentCatalog=catlog;
col1.Type=ADOX.DataTypeEnum.adInteger;
col1.Name=\"StuId\";
col1.Properties[\"JetOLEDB:AllowZeroLength\"].Value=false;
col1.Properties[\"AutoIncrement\"].Value=true;
//NameColumn
ADOX.ColumnClasscol2=newADOX.ColumnClass();
col2.ParentCatalog=catlog;
col2.Name=\"StuName\";
col2.Properties[\"JetOLEDB:AllowZeroLength\"].Value=false;
//AgeColumn
ADOX.ColumnClasscol3=newADOX.ColumnClass();
col3.ParentCatalog=catlog;
col3.Name=\"Stuage\";
col3.Type=DataTypeEnum.adDouble;
col3.Properties[\"JetOLEDB:AllowZeroLength\"].Value=false;
//Primary
table.Keys.Append(\"PrimaryKey\",ADOX.KeyTypeEnum.adKeyPrimary,\"StuId\",\"\",\"\");
table.Columns.Append(col1,ADOX.DataTypeEnum.adInteger,0);
table.Columns.Append(col3,ADOX.DataTypeEnum.adDouble,666);
table.Columns.Append(col2,ADOX.DataTypeEnum.adVarChar,25);
catlog.Tables.Append(table);
System.Runtime.InteropServices.Marshal.ReleaseComObject(table);
System.Runtime.InteropServices.Marshal.ReleaseComObject(catlog);
table=null;
catlog=null;
GC.WaitForPendingFinalizers();
GC.Collect();
}
}
}
本文链接: http://adoxgroup.immuno-online.com/view-744008.html
发布于 : 2021-03-25
阅读(0)
最新动态
2021-03-25
2021-03-25
2021-03-25
2021-03-25
2021-03-25
2021-03-25
2021-03-25
2021-03-25
2021-03-25
2021-03-25
2021-03-25
2021-03-25