using System; using System.Data; using System.Configuration; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; using System.Data.OleDb; /// /// Summary description for DALUtilities /// public class DALUtilities { OleDbConnection dbConnection; OleDbCommand dbCommand; OleDbDataAdapter dbAdapter; public string strCommand; static string ConnString = ConfigurationSettings.AppSettings["ConString"]; public DALUtilities() { // // TODO: Add constructor logic here // } private void GetConnection() { try { dbConnection = new OleDbConnection(ConnString); //dbConnection.Open(); } catch (Exception ex) { /*logging code*/ Console.WriteLine(ex.Message); throw new Exception(); } } private void getCommand() { try { dbCommand = new OleDbCommand(strCommand); dbCommand.CommandType = CommandType.Text; } catch (Exception ex) { /*logging code*/ throw new Exception(); } } private void getAdapter() { try { getCommand(); GetConnection(); dbAdapter = new OleDbDataAdapter(dbCommand.CommandText, dbConnection); } catch (Exception) { throw; } } public DataSet ExcuteQuery() { try { DataSet ds = new DataSet(); getAdapter(); dbAdapter.Fill(ds); return ds; } catch (Exception ex) { Console.WriteLine(ex.Message); throw; } } public void ExcuteNonQuery() { try { GetConnection(); dbCommand.Connection = dbConnection; dbCommand.ExecuteNonQuery(); } catch (Exception ex) { /*logging code*/ throw new Exception(); } } public static string getConnectionString() { //string strPath = "../database\\ecodb.mdb"; // HttpContext.Current.Server.MapPath("../database/ecodb.mdb"); //return "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\""+strPath+"\""; return ConfigurationSettings.AppSettings["ConString"]; } }