View Single Post
  #2 (permalink)  
Old August 30th, 2009, 11:26 PM
DungPT DungPT is offline
Registered User
Join Date: Aug 2009
Posts: 4
Thanks: 1
Thanked 0 Times in 0 Posts


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.


Last edited by DungPT; September 1st, 2009 at 01:24 AM..