public QuickBooksSynchService(string companyName) { // Make sure the name of QODBC company is same as passed in using (var con = new OdbcConnection(qodbcConnectionString)) using (var cmd = new OdbcCommand("select top 1 CompanyName from Company", con)) { con.Open(); string currentCompany = (string)cmd.ExecuteScalar(); if (companyName != currentCompany) { throw new Exception("Wrong company - expecting " + companyName + ", got " + currentCompany); } } // Get the company ID using the name passed in (row with matching name must exist) using (var repo = new AccountingRepository(new AccountingContext(), true)) { this.companyID = repo.CompanyFileByName(companyName).CompanyId; } }