Connecting Oracle using ODP.NET with Enterprise Library DAAB

后端 未结 2 883
-上瘾入骨i
-上瘾入骨i 2021-01-15 19:58

Our application is using Enterprise Library DAAB to support both oracle and sql databases.

One of the Stored Procedure is for uploading Image to Table. It\'s a BLO

相关标签:
2条回答
  • 2021-01-15 20:41

    I hope the following steps will give you the correct result.

    To replace System.Data.OracleClient with Oracle.DataAccess.Client; and Oracle.DataAccess.Types

    Download and install the latest version of Microsoft Enterprise Library ver 3.1 Can be found here:- http://msdn2.microsoft.com/en-us/library/aa480453.aspx

    Download and install the Oracle ODP.Net from Oracle website Your DLL file should be in :- C:\oracle\product\11.1.0\client_1\odp.net\bin\2.x\Oracle.DataAccess.dll

    When it prompts you to install the source do so by using the checkbox.

    If you didn't then run the msi on the following path C:\Program Files\Microsoft Enterprise Library 3.1 - May 2007\src

    The code for the library gets stored on the following path C:\EntLib3Src\App Blocks

    Take a backup of the original src folder in case you need them later - C:\EntLib3Src\App Blocks\Src

    Open the solution file EnterpriseLibrary.sln And get to the data project under Data Access Application Block

    Add Oracle.DataAccess.dll Reference to the Data Project. Your DLL file should be in :- C:\oracle\product\11.1.0\client_1\odp.net\bin\2.x\Oracle.DataAccess.dll

    Search and replace the following [ Instead you could download and use the updated DLL thats attached to this article]

    File :- C:\EntLib3Src\App Blocks\Src\Data\Oracle\OracleDatabase.cs
    File :- C:\EntLib3Src\App Blocks\Src\Data\DatabaseConfigurationView.cs
    File :- C:\EntLib3Src\App Blocks\Src\Data\Oracle\OracleDataReaderWrapper.cs

    Find :- using System.Data.OracleClient;
    Replace with:- using Oracle.DataAccess.Client; using Oracle.DataAccess.Types;

    File :- C:\EntLib3Src\App Blocks\Src\Data\Configuration\DbProviderMapping.cs Class:- DbProviderMapping

    Find :- System.Data.OracleClient
    Replace with:- Oracle.DataAccess.Client

    File :- C:\EntLib3Src\App Blocks\Src\Data\Configuration\Manageability\ ConnectionStringsManageabilityProvider.cs
    Method:- AddAdministrativeTemplateDirectives
    Find :- System.Data.OracleClient
    Replace with:- Oracle.DataAccess.Client

    File :- C:\EntLib3Src\App Blocks\Src\Data\Oracle\OracleDatabase.cs
    Method:- AddParameter

    Find :- public void AddParameter(OracleCommand command, string name, OracleType oracleType, int size, ParameterDirection direction, bool nullable, byte precision, byte scale, string sourceColumn, DataRowVersion sourceVersion, object value)

    Replace with:- public void AddParameter(OracleCommand command, string name, OracleDbType oracleType, int size, ParameterDirection direction, bool nullable, byte precision, byte scale, string sourceColumn, DataRowVersion sourceVersion, object value)

    Reason:- OracleType replaced with OracleDbType as the third parameter as that the type name in the odp.net API

    File:- C:\EntLib3Src\App Blocks\Src\Data\Oracle\OracleDatabase.cs
    Remove:- [OraclePermission(SecurityAction.Demand)] -

    Haven't got a clue what that does if someone does please brief on feedback session

    File:- C:\EntLib3Src\App Blocks\Src\Data\Oracle\OracleDatabase.cs
    Find:- OracleType.Raw
    Replace with:- OracleDbType.Raw

    Find:- param.OracleType
    Replace with:- param.OracleDbType

    Find:- OracleType.Cursor
    Replace with:- OracleDbType.RefCursor

    Find:- parameter.OracleType
    Replace with:- parameter.OracleDbType

    Compile now and if you get an error do the following Warning as Error : XML comment on - Remove the highlighted error content / replace it with approp comment Hopefully it should compile fine now.

    Now the DLL that was generated by compiling the above project can be used against both SqlServer and Oracle [ODP.Net]

    0 讨论(0)
  • 2021-01-15 20:45

    Bit late on this, but I can't see a good reason why the responder suggested the use of EL3.1 That is very out of date - 5 is the latest version (and was out for almost 2 years before this post) and the OP was using 4.1 according to the code sample. It is much simpler to use ODP with EL5 (have done so myself, utilising the EntlibContrib project) and although I cannot speak for any potential issues with parameter sizes as we do not use BLOBs, EntlibContrib natively allows the use of the OracleDbType so I think it probably wouldn't be a problem.

    Just in case anyone stumbles on this post wondering how to get EL5 and ODP playing nicely with minimum fuss I can supply details - PM me.

    0 讨论(0)
提交回复
热议问题