The Artima Developer Community
Sponsored Link

.NET Buzz Forum
Universal DAL

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Paschal

Posts: 1621
Nickname: bigapple
Registered: Nov, 2003

Paschal is a .Net developer
Universal DAL Posted: Mar 10, 2004 4:05 PM
Reply to this message Reply

This post originated from an RSS feed registered with .NET Buzz by Paschal.
Original Post: Universal DAL
Feed Title: help.net
Feed URL: http://www.asp.net/err404.htm?aspxerrorpath=/pleloup/Rss.aspx
Feed Description: .Net for mankind !
Latest .NET Buzz Posts
Latest .NET Buzz Posts by Paschal
Latest Posts From help.net

Advertisement

David L. Penton will show at the Plano Dot.Net Users group (http://www.pdnug.net/) something I really want to have my hands on, an universal DAL (SQL, Oracle, Access, etc...)

The news was posted only in a mail list so I post it back here in case you're interested:

"

I will blog about it as well as post on the PDNUG...
Here is a quick synopsis of what this is about (I removed a lot of comments and compiler directives)...

public class DBHelper
{
#region public enum DBLibrary

public enum DBLibrary
{
SqlClient,
OleDb,
Odbc,
OracleClient,
None
}

#endregion

#region public static void SetDBLibrary(DBLibrary dbLibrary)

/// <summary>
/// Holds the local client library to use
/// This is your default library to use
/// </summary>

private static DBLibrary dbLibrary = DBLibrary.SqlClient;
public static void SetDBLibrary(DBLibrary dbLibrary)
{
if (!Enum.IsDefined(typeof(DBLibrary), dbLibrary))
    throw new ArgumentOutOfRangeException("dbLibrary");
if(dbLibrary == DBLibrary.None)
    throw new ArgumentOutOfRangeException(
"dbLibrary"
, "The value \"None\" means no provider, which is not allowed.");

DBHelper.dbLibrary = dbLibrary;
}

#endregion

#region GetDbConnection

public static IDbConnection
GetDbConnection(System.String connectionString)
{
IDbConnection conn = null;
switch(dbLibrary)
{
case DBLibrary.SqlClient :
conn = new SqlConnection(connectionString);
break;
case DBLibrary.OleDb :
conn = new OleDbConnection(connectionString);
break;
case DBLibrary.Odbc :
conn = new OdbcConnection(connectionString);
break;
case DBLibrary.OracleClient :
conn = new OracleConnection(connectionString);
break;
default :
break;
}
return conn;
}

#endregion

}

 
Then in your code you do this:

IDbConnection conn = DBHelper.GetDbConnection(connString);

You would probably not even use this particular method unless you were going to use transactions. But, there are a number of other functions, namely ExecuteDataSet/ExecuteDataTable/ExecuteDataRow/ExecuteScalar/ExecuteNonQuery (among others)

This does make it very easy to add support for other providers (that follow the interfacing rules in System.Data).

"

 From David L. Penton, Microsoft MVP

Read: Universal DAL

Topic: DefaultButton Previous Topic   Next Topic Topic: The truth about choosing keywords

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use