Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / August 2007

Tip: Looking for answers? Try searching our database.

Doubt connections

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Paulo - 27 Aug 2007 14:06 GMT
Hi, if the customer choose access (mdb) I have to use OleDbConnection,
OleDbCommand classes, etc... etc, but if the customer chooses Sql Server as
database I have to use SqlConnection, SqlDataReader, etc...

Do you know any pieces of code / classes wich gives to me the flexibility to
choose between those databases?

Thanks!
sloan - 27 Aug 2007 15:36 GMT
Get the enterprise library 3.1 version.

It will abstract you "up one level", so you're not super tied to 1 rdbms.
(even though I don't consider access a true rdbms)

......

Another option is to write a data-access-layer, via an interface.

Interface IEmployeeData

and then have 2 concrete versions of IEmployeeData

example:

   interface IEmployeeData
       IDataReader GetAllEmployees();
       IDataReader GetSomeEmployess( Guid deptUUID ) ;
       void UpdateEmployee ( Guid empUUID, string lastName , string
firstName , string ssn , Guid deptUUID ) ;
       void DeleteEmployee ( Guid empUUID) ;

and then implement one for SqlServer, and 1 for Access.

public class EmployeeDataViaSqlServer : IEmployeeData

public class EmployeeDataViaAccess : IEmployeeData

Its called the Factory Design Pattern.

http://sholliday.spaces.live.com/Blog/cns!A68482B9628A842A!126.entry

http://www.dofactory.com/Patterns/PatternFactory.aspx

The reason I mention the factory pattern is because of the large differences
in ways you're going to code up a DAL for the two.

Sql Server has stored procedures, which most commonly you're gonna add
parameters to.
db.AddInParameter ( )

Access, you don't have stored procedures.   So the code is going to look
different.

.........

I have done the IEmployeeData thing, and I use the Ent Library 3.1 within
that setup.  I use the "key" model (my blog entry) to decide which concrete
version to give back.

But as long as your biz layer uses the IEmployeeData interface, you'll be
good.  And you'll need to learn how to work with the IDataReader interface
instead of a concrete version.

> Hi, if the customer choose access (mdb) I have to use OleDbConnection,
> OleDbCommand classes, etc... etc, but if the customer chooses Sql Server
[quoted text clipped - 4 lines]
>
> Thanks!

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.