因為特殊需要,需要獲取dbf數據庫中的表的名稱。現有 如下解決辦法
1 public List<string> GetTableFields(string path) 2 { 3 List<string> tables = new List<string>(); 4 var dt = GetSchemaTable(ConnectionString); 5 foreach (DataRow dr in dt.Rows) 6 { 7 tables.Add(dr["COLUMN_NAME"] as string); 8 } 9 return tables; 10 } 11 12 private DataTable GetSchemaTable(string connectionString) 13 { 14 using (OleDbConnection connection = new 15 OleDbConnection(connectionString)) 16 { 17 connection.Open(); 18 DataTable schemaTable = connection.GetOleDbSchemaTable( 19 OleDbSchemaGuid.Columns, 20 new object[] { null, null, null, null }); 21 return schemaTable; 22 } 23 }