用ado.net取数据库中table、column的信息
1.获取数据库中所有的表
con是oledbConnetion
schemaTbl.Rows[0][“TABLE_NAME”]为table的名字
2.取某个表中所有的column
schemaCols.Rows[0][“COLUMN_NAME”]为column的名字
object[] objArrRestrict;
objArrRestrict = new object[] {null, null, null, "TABLE"};
DataTable schemaTbl = con.GetOleDbSchemaTable(OleDbSchemaGuid.Tables,objArrRestrict);
objArrRestrict = new object[] {null, null, null, "TABLE"};
DataTable schemaTbl = con.GetOleDbSchemaTable(OleDbSchemaGuid.Tables,objArrRestrict);
schemaTbl.Rows[0][“TABLE_NAME”]为table的名字
2.取某个表中所有的column
object[] objArrRestrict;
objArrRestrict = new object[] {null, null, selTbl, null};
DataTable schemaCols = con.GetOleDbSchemaTable(OleDbSchemaGuid.Columns, objArrRestrict);
objArrRestrict = new object[] {null, null, selTbl, null};
DataTable schemaCols = con.GetOleDbSchemaTable(OleDbSchemaGuid.Columns, objArrRestrict);