using System;
using System.Data;
using System.Data.OleDb;

namespace car
{
   public class DataBase
    {
        private OleDbCommand cmd;
        private OleDbConnection con;
        private OleDbDataAdapter da;
        private DataTable dt;

        public void DoCommand(string ole)
        {
            con = new OleDbConnection();

            con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=cardb.mdb;Persist Security Info=True";

            cmd = new OleDbCommand();
            cmd.Connection = con;
            con.Open();
            cmd.CommandText = ole;
            cmd.ExecuteNonQuery();
            con.Close();
        }

        public DataTable MySelect(string sql)
        {
            con = new OleDbConnection();
            con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=cardb.mdb;Persist Security Info=True;";
            cmd = new OleDbCommand();
            cmd.Connection = con;
            da = new OleDbDataAdapter(cmd);
            dt = new DataTable();
            con.Open();
            cmd.CommandText = sql;
            da.Fill(dt);
            con.Close();
            return dt;
        }
    }
}
