1String connectionString ="Provider=Microsoft.Jet.OLEDB.4.0;Data source=| Datadirectory|aspxweb2.mdb;";2OleDbConnection conn =NewOleDbConnection (connectionString);3 Conn. Open ();4 DataTable schematable;5DataTable DT = conn. GetOleDbSchemaTable (OleDbSchemaGuid.Tables,New Object[] {NULL,NULL,NULL,"TABLE" });6 for(inti =0; i < dt. Rows.Count; i++)7 {8String tableName = dt. rows[i]["table_name"]. ToString ();9Response.Write (""+ TableName +"");Tenschematable = conn. GetOleDbSchemaTable (OleDbSchemaGuid.Columns,NewObject[] {NULL,NULL, TableName,NULL }); One for(intj =0; J < SchemaTable.Rows.Count; J + +) A { -Response.Write ("<li> field Name:"+ schematable.rows[j]["column_name"]. ToString () +"Type:"+ (OleDbType) schematable.rows[j]["data_type"] +"</li>"); - } the } -Conn. Close ();
Http://www.2cto.com/kf/201203/125618.html
C # Open the MDB file, get all the tables under the file, and get all the fields under the table