using System; using System.Collections; using System.Data; using System.Data.OleDb; namespace TheBlackReverand.SQL.Tools { public static class AccessTools { public static DataTable Executer(OleDbConnection connexion, string sql, bool avecRetour) { if (avecRetour == true) try { OleDbDataAdapter DA = new OleDbDataAdapter(sql, connexion); DataTable DT = new DataTable(); DA.Fill(DT); return DT; } catch (OleDbException ex) { throw new Exception(ex.Message, ex); } else try { OleDbCommand C = new OleDbCommand(sql, connexion); C.ExecuteNonQuery(); return null; } catch (OleDbException ex) { throw new Exception(ex.Message, ex); } } public static string ConnectionString(string path) { return String.Format("Provider=Microsoft.Jet.OLEDB.4.0; Data Source={0}", path); } public static ArrayList Tables(OleDbConnection connexion) { ArrayList _tables = null; DataTable _lstBases = connexion.GetSchema("TABLES"); if (_lstBases != null) { _tables = new ArrayList(); foreach (DataRow _row in _lstBases.Rows) if (_row["TABLE_TYPE"].ToString() == "TABLE") _tables.Add(_row["TABLE_NAME"]); } return _tables; } } }