String connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|aspxWeb2.mdb;";
OleDbConnection conn = new OleDbConnection(connectionString);
conn.Open();
DataTable schemaTable;
DataTable dt = conn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, new object[] { null, null, null, "TABLE" });
for (int i = ; i < dt.Rows.Count; i++)
{
String tableName = dt.Rows[i]["TABLE_NAME"].ToString();
Response.Write("<h1>" + tableName + "</h1>");
schemaTable = conn.GetOleDbSchemaTable(OleDbSchemaGuid.Columns, new Object[] { null, null, tableName, null });
for (int j = ; j < schemaTable.Rows.Count; j++)
{
Response.Write("<li>字段名称:" + schemaTable.Rows[j]["COLUMN_NAME"].ToString() + " 类型:" + (OleDbType)schemaTable.Rows[j]["DATA_TYPE"] + "</li>");
}
}
conn.Close();
http://www.2cto.com/kf/201203/125618.html