--- h6-udlÃ¥nssystemDlg.cpp 2006/09/05 12:50:38 41 +++ h6-udlÃ¥nssystemDlg.cpp 2006/09/06 20:27:24 47 @@ -8,10 +8,13 @@ #include "h6-udlånssystemDlg.h" #include ".\h6-udlånssystemdlg.h" +#include "ConfigFile.h" #include "commonstorage.h" + #include "databaselayer.h" #include "microsoftdblayer.h" #include "mysqllayer.h" +#include "postgreslayer.h" #ifdef _DEBUG #define new DEBUG_NEW @@ -111,15 +114,32 @@ m_tabs.Init(); m_tabs.SetCurSel(0); + ConfigFile config; + try { + config.Read(); + } catch(...) { + MessageBox("Could not open config file"); + OnOK(); + } try { - //DatabaseLayer *dbl = new DatabaseLayer; - DatabaseLayer *dbl = new MySQLLayer; + DatabaseLayer *dbl = 0; + if (config.driver.MakeLower() == "mysql") + dbl = new MySQLLayer(config); + else if (config.driver.MakeLower() == "postgresql") + dbl = new PostgresLayer(config); + else if (config.driver.MakeLower() == "microsoftsql") + dbl = new MicrosoftDBLayer(config); + else { + CString tmp; + tmp.Format("Unsupported driver: %s", config.driver); + MessageBox(tmp); + OnOK(); + } CommonStorage::Instance()->setDBLayer(dbl); } catch (...) { MessageBox(CString("Could not establish connection to the database server\r\n") + - "Please contact your network administrator\r\n" + - "(This application shuts down automatically)"); + "Please contact your network administrator"); OnOK(); }