0

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

ScottCher
  • 14,651
  • 6
  • 26
  • 25
Brian G Swanson
  • 1,039
  • 7
  • 17
  • SOS's link is correct. I had to download it the other day. ApplicationBlocks seems to have been left by the wayside my LINQ and ORM frameworks. – Dana Sep 25 '08 at 17:22

2 Answers2

2

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.