2020-09-02

tech2022-08-09  132

“标题”

using System; using System.Collections.Generic; using System.Text; using ADOX; using System.IO; namespace testADOX { class Program { static void Main(string[] args) { FileStream F = new FileStream("e://sample.txt", FileMode.Create, FileAccess.ReadWrite, FileShare.ReadWrite); ADOX.Catalog catalog = new Catalog(); StreamWriter sw = new StreamWriter(F) ; string sAcessConnection = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=e://ss1-总.mdb;Jet OLEDB:Engine Type=5"; ADODB.Connection cn = new ADODB.Connection(); cn.Open(sAcessConnection,null,null,-1); catalog.ActiveConnection = cn; ADOX.Table table = new ADOX.Table(); table.ParentCatalog = catalog; for (int i = 0; i <catalog.Tables.Count; i++) { sw.WriteLine("{0},{1}",catalog.Tables[i].Name,i); sw.WriteLine(catalog.Tables[i].Type); for (int j = 0; j < catalog.Tables[i].Columns.Count; j++) { sw.WriteLine("{0},{1},{2}", catalog.Tables[i].Columns[j].Name, i, j); sw.WriteLine("{0},{1},{2}", catalog.Tables[i].Columns[j].Type, i, j); } } sw.WriteLine(catalog.Tables.Count); cn.Close(); sw.Close(); F.Close(); } } }

如何读取mdb数据库中表的名字,列的名字和类型

输出的数据库表名称以及列名称是按照字母顺序输出的,并没有和ACESS打开的顺序一致。这什么原因?

 

最新回复(0)