using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Data.SqlClient; using System.Configuration; namespace bnhtrade.Core.Data.Database { public class Connection { //protected readonly string SqlConnectionString; private Model.Credentials.bnhtradeDB dbCredentials; protected string SqlConnectionString { get { return dbCredentials.ConnectionString; } } public Connection() { // attempt to retrive credentials from app.local.config try { var dbCredentials = new bnhtrade.Core.Model.Credentials.bnhtradeDB( ConfigurationManager.AppSettings["DbDataSource"] , ConfigurationManager.AppSettings["DbUserId"] , ConfigurationManager.AppSettings["DbUserPassword"] ); this.dbCredentials = dbCredentials; } catch(Exception ex) { throw new Exception("Unable to retirve DB credentials: " + ex.Message); } } public Connection(Model.Credentials.bnhtradeDB dbCredentials) { // setup sql parameters if (dbCredentials == null) { throw new Exception("DB credentials object is null"); } } } }