views:

437

answers:

2

I've found mention of a data application block existing for ODBC, but can't seem to find it anywhere. If i didn't have a copy of the Access DB application block I wouldn't believe it ever existed either.

Anyone know where to download either the DLL or the code-base from?

--UPDATE: It is NOT included in either the v1, v2, or Enterprise Library versions of the Data ApplicationBlocks

Thanks, Brian Swanson

+1  A: 

Which version of .net are you interested in using the ODBC block on?

The Enterprise library has a Data Access component. It is useful on SQL, Oracle, and ODBC. Just set a different provider name in the .config file EX:

<add name="MyConnection" connectionString="Dsn=Datasource;uid=UserID;pwd=Password" providerName="System.Data.Odbc" />

At that point, the data access code is "standardized" and looks identical for SQL, Oracle, and ODBC

EX:

Imports Microsoft.Practices.EnterpriseLibrary.Data
Imports Microsoft.Practices.EnterpriseLibrary.ExceptionHandling

    Public Class MyClass

    Private dbMyDatabase As Database

    dbMyDatabase = DatabaseFactory.CreateDatabase("MyConnection")

    Public Function GetMyData(ByVal FacilityCode As String) As Data.DataSet

         Try
          Dim SQL As String
          SQL = "SELECT * from MyDataTable"
          Dim cmd As Data.Common.DbCommand = dbMyDatabase.GetSqlStringCommand(SQL)
          Return dbMyDatabase.ExecuteDataSet(cmd)
         Catch ex As Exception
          ExceptionPolicy.HandleException(ex, "All")
          Throw
         End Try
        End Function 

    End Class

The address for the latest Enterprise Library is: http://msdn.microsoft.com/en-us/library/cc467894.aspx

This is assuming you are using .net 3x.

Also note that we are using the Exception Handling block in the above code.

ChrisC_46259