p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   BOOK: ASP.NET 3.5 Enterprise Application Development with Visual Studio 2008: Problem Design Solutio (http://p2p.wrox.com/forumdisplay.php?f=477)
-   -   DBHelper Class ?? (http://p2p.wrox.com/showthread.php?t=75949)

mdfinch August 28th, 2009 03:19 PM

DBHelper Class ??
This is probably a dumb question from a beginner but I will ask it anyway.

Where did the DBHelper Class come from? It is not in the source code from Chapter 2 but does show up in the source for Chapter 3. I have scanned the book and cannot find it mentioned in the text (and only in code) on page 162 in Chapter 6.

Did I miss something somewhere? Is this a class that created automatically or in what Chapter does it discuss creating this class and why?

Thanks for your tolerance.

DungPT August 30th, 2009 11:26 PM


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:


- 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):



Hope this help.


All times are GMT -4. The time now is 07:47 PM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.