You are right. DBHelper class is not mentioned in the text of this book. But this bug is noticed by Varallo on page 44. So you can download the code(include DBHelper class) for Chapter 2 (Revised 4/1/09) now.
By default, HRPaidTimeOff application uses connection string in settings file of DAL, but you should use DBHelper class to get connection string in web.config file instead.
- Using HRPaidTimeOffDataContext's default constructor may be causing some errors because when you drag tables or stored procedures to the ORM Designer, the connection string in settings file may be changed or something like that.
In some case, HRpaidTimeOffConnectionString1 is added automatically to settings file. So you can get errors when settings file uses HRpaidTimeOffConnectionString1, but HRPaidTimeOff.designer.cs still uses HRpaidTimeOffConnectionString, for example.
using(HRPaidTimeOffDatacontext db = new HRPaidTimeOffDataContext())
See more in this link:
Login failed for database user
- Using DBHelper class is easy to manage, you can edit the connection strings in IIS, for example.
using(HRPaidTimeOffDatacontext db = new HRPaidTimeOffDataContext(DBHelper.GetHRPaidTimeOffConnectionString()))
Check this link (If you need):
Need help about DbHelper class.
Hope this help.