/// <Summary> <br/> // return all table names in the mdb database <br/> /// </Summary> <br/> Public String [] getshematablename (string database_path, string database_password) <br/>{< br/> try <br/>{< br/> // obtain the data table <br/> oledbconnection conn = new oledbconnection (); <br/> Conn. connectionstring = "provider = Microsoft. jet. oledb.4.0; Jet oledb: Database Password = '"+ database_password +" Data Source = "+ database_path; <br/> Conn. open (); <br/> datatable shematable = Conn. getoledbschematable (oledbschemaguid. tables, new object [] {null, "table"}); <br/> int n = shematable. rows. count; <br/> string [] strtable = new string [N]; <br/> int M = shematable. columns. indexof ("table_name"); <br/> for (INT I = 0; I <n; I ++) <br/>{< br/> datarow m_datarow = shematable. rows [I]; <br/> strtable [I] = m_datarow.itemarray.getvalue (m ). tostring (); <br/>}< br/> return strtable; <br/>}< br/> catch (oledbexception ex) <br/>{< br/> MessageBox. show ("the specified restriction set is invalid:/N" + ex. message); <br/> return NULL; <br/>}< br/> finally <br/>{< br/> Conn. close (); <br/> Conn. dispose (); <br/>}< br/>}
/// <Summary> <br/> // return all field names of a table <br/> /// </Summary> <br/> Public String [] gettablecolumn (string database_path, string vartablename) <br/>{< br/> datatable dt = new datatable (); <br/> try <br/>{< br/> conn = new oledbconnection (); <br/> Conn. connectionstring = "provider = Microsoft. jet. oledb.4.0; Data Source = "+ database_path; <br/> Conn. open (); <br/> dt = Conn. getoledbschematable (oledbschemaguid. columns, new object [] {null, null, vartablename, null}); <br/> int n = DT. rows. count; <br/> string [] strtable = new string [N]; <br/> int M = DT. columns. indexof ("column_name"); <br/> for (INT I = 0; I <n; I ++) <br/>{< br/> datarow m_datarow = DT. rows [I]; <br/> strtable [I] = m_datarow.itemarray.getvalue (m ). tostring (); <br/>}< br/> return strtable; <br/>}< br/> catch (exception ex) <br/>{< br/> throw ex; <br/>}< br/> finally <br/>{< br/> Conn. close (); <br/>}< br/>}