Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 2005 > C# 2005
|
C# 2005 For discussion of Visual C# 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# 2005 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 April 8th, 2008, 01:03 AM
Authorized User
 
Join Date: Mar 2008
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to vgsgowrisankar
Default .Net Application with Multiple Database

hello friends, i need the general logical idea regarding multiple database support. my Boss gave a project. but he would like to do that project with multiple supporting database. especially sql server 2005, oracle and foxpro. if the client need sql then we provide the application with sql db . suppose the client need the oracle database we will provide the same software with oracle db and same for foxpro. so i want to write the code for all 3 database in my coding part. is it possible to do this kind of 3 database support. if its right which is the correct way to do this project.

urgent please help me .
 
Old April 8th, 2008, 01:31 AM
Friend of Wrox
 
Join Date: Mar 2007
Posts: 432
Thanks: 0
Thanked 1 Time in 1 Post
Default

Of course you can, this is where the real benefits of a well-designed Data Access Layer (DAL) come in to play.

I would say:
Create an abstract DAL layer (i.e. one that doesnt care which managed provider it is using) this one should be accessed by you client code. The client code would need a reference to a concrete (subclass) of this abstract DAL passed to it.

Then you design the concrete DAL, one for each managed provider. Implementing all the required methods (e.g. GetCustomerDetails or whatever).

Then, at run time you select what provider you wish to use (either by user selection, or most likely, app.config). It passes the concrete DAL to the client code, transparantly allowing access to that data source.

Key Design Point: Encapsulate what varies

I hope this steers you in the right direction :)

Rob
The Developing Developer
Currently Working Towards: MCAD C#
My Blog: http://www.robzyc.spaces.live.com
<center>"Nothing can stop the man with the right mental attitude from achieving his goal;
nothing on earth can help the man with the wrong mental attitude".

Thomas Jefferson</center>
 
Old April 8th, 2008, 01:49 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

If you use the Microsoft's Patterns & Practices Enterprise Application Data Access Layer (DAL) and only utilise features common to all databases you are going to supoport then this is relatively easy as the DAL abstracts the common tasks of calling stored procedures and running SQL statements. For eaxmple store procedure parameters in SQL Server are prefixed with '@' whereas in Oracle they begin with ':'. Using the DAL you can just call them by name and the DAL will use the correct prefix based on the connection string details. SQL Server and Oracle should be okay but FoxPro doesn't have the advanced features of these and uses other methods so you'll need to stick to basic SQL constructs. I'm also unsure as to whether FoxPro has a .NET data provider, I believe you'll need the OLEDB generic one.

--

Joe (Microsoft MVP - XML)
 
Old April 8th, 2008, 09:17 AM
Authorized User
 
Join Date: Mar 2008
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to vgsgowrisankar
Default

hai , Thank you for your guidelines sir. i am trying.
 
Old April 8th, 2008, 11:20 AM
Authorized User
 
Join Date: May 2006
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to notrosh
Default

I have used the abstract factory pattern for this very issue many times.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Packaging an VB.NET Database Application fantom222 VB.NET 9 September 2nd, 2007 03:44 AM
Multiple forms in one application lily611 General .NET 12 December 27th, 2006 08:21 AM
Single or Multiple application. Gibs_poovath General .NET 7 May 25th, 2004 07:54 AM
Packaging an VB.NET Database Application fantom222 VB How-To 2 June 30th, 2003 12:55 AM





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