Wrox Programmer Forums
|
BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0
This is the forum to discuss the Wrox book ASP.NET 2.0 Website Programming: Problem - Design - Solution by Marco Bellinaso; ISBN: 9780764584640
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 26th, 2009, 10:03 AM
Authorized User
 
Join Date: Mar 2009
Posts: 75
Thanks: 16
Thanked 1 Time in 1 Post
Default Question about DAL Providers

Won't it be better to use DbProviderFactory instead of using the similar technique presented in the book?
This will save us of creating similar DAL implementations for different Databases like SqlArticlesProvider class, and creating it's instances with Activator.CreateInstance(...).

Are there some limitations?
 
Old August 1st, 2009, 05:21 PM
Lee Dumond's Avatar
Wrox Author
 
Join Date: Jan 2008
Posts: 923
Thanks: 12
Thanked 166 Times in 162 Posts
Default

The application does essentially use the Factory pattern, but instead of calling it DbProviderFactory, it calls it SiteProvider.

Either way, you still need to provide seperate implementations for each database type (SQL, Oracle, DB2, Vista, or whatever) and create an instance of the required provider as needed.
__________________
Visit my blog at http://leedumond.com
Follow me on Twitter: http://twitter.com/LeeDumond

Code:
if (this.PostHelpedYou)
{
   ClickThanksButton(); 
}
 
Old August 2nd, 2009, 05:54 AM
Authorized User
 
Join Date: Mar 2009
Posts: 75
Thanks: 16
Thanked 1 Time in 1 Post
Default

Quote:
Originally Posted by Lee Dumond View Post
Either way, you still need to provide seperate implementations for each database type (SQL, Oracle, DB2, Vista, or whatever) and create an instance of the required provider as needed.
Why? can't dbfactory handle all of them?
 
Old August 2nd, 2009, 09:53 PM
Lee Dumond's Avatar
Wrox Author
 
Join Date: Jan 2008
Posts: 923
Thanks: 12
Thanked 166 Times in 162 Posts
Default

A DbFactory would only be responsible for instantiating the correct provider. You still have to write classes that provide low-level interaction with the various databases.
__________________
Visit my blog at http://leedumond.com
Follow me on Twitter: http://twitter.com/LeeDumond

Code:
if (this.PostHelpedYou)
{
   ClickThanksButton(); 
}
 
Old August 3rd, 2009, 04:04 AM
Authorized User
 
Join Date: Mar 2009
Posts: 75
Thanks: 16
Thanked 1 Time in 1 Post
Default

I am talking about:

Code:
  using (SqlConnection cn = new SqlConnection(this.ConnectionString))
            {
                SqlCommand cmd = new SqlCommand("tbh_Articles_GetCategoryByID", cn);
Can't I change it to something like:

Code:
DbProviderFactory factory = DbProviderFactories.GetFactory(ProviderName);

            using (DbConnection cn = factory.CreateConnection())
            {
                DbCommand cmd =cn.CreateCommand();
So this will work with all databases?
 
Old August 4th, 2009, 11:58 AM
Lee Dumond's Avatar
Wrox Author
 
Join Date: Jan 2008
Posts: 923
Thanks: 12
Thanked 166 Times in 162 Posts
Default

What exactly is your GetFactory method "getting"? It's getting a "factory", which is just another fancy name for "provider". And you still need separate factories for each database.
__________________
Visit my blog at http://leedumond.com
Follow me on Twitter: http://twitter.com/LeeDumond

Code:
if (this.PostHelpedYou)
{
   ClickThanksButton(); 
}
 
Old August 4th, 2009, 04:30 PM
Authorized User
 
Join Date: Mar 2009
Posts: 75
Thanks: 16
Thanked 1 Time in 1 Post
Default

Sorry but i am not getting through ,
asp.net provides 4 factories Odbc, OleDb ,Oracle and Sql.
So with one "generic" implementation I deal with those 4 databases, right?
(instead of SqlArticlesProvider.cs for sql only I can create generic implementation for 4 dbs)

So my initial question was why to reinvent the wheel ?

And thanks for your patience

Last edited by yevi; August 4th, 2009 at 04:34 PM..





Similar Threads
Thread Thread Starter Forum Replies Last Post
Access Providers not working chroniclemaster1 ASP.NET 2.0 Basics 4 March 18th, 2008 09:55 PM
Providers!!! dpkbahuguna Beginning VB 6 0 July 2nd, 2007 07:17 AM
Personalization Providers AGS BOOK: Professional ASP.NET 2.0 and Special Edition; ISBN: 978-0-7645-7610-2; ISBN: 978-0-470-04178-9 0 December 3rd, 2005 08:44 AM
Custom Providers bmains ASP.NET 2.0 Basics 1 September 15th, 2004 12:30 PM





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