Parameter discovery is not supported for connections using GenericDatabase

Topics: Data Access Application Block
May 21, 2007 at 11:14 PM
Hi. We have an ASP.NET 2.0 application running with an Oracle 10g database. We're using the EntLib 2.0 DAAB.

My code breaks on the following line:

DbCommand cmd = Repository.Database.GetStoredProcCommand(StoredProc.LookupManager.GetLookupInfo,lookupId);

The Database in the Repository.Database portion of the line refers to:

Microsoft.Practices.EnterpriseLibrary.Data.GenericDatabase

The full error is:

Parameter discovery is not supported for connections using GenericDatabase. You must specify the parameters explicitly, or configure the connection to use a type deriving from Database that supports parameter discovery.

I saw a reference for why I'm getting the error here:

http://blogs.msdn.com/tomholl/archive/2005/09/14/466298.aspx

The question is, how do I make it so that the EntLib remembers that I'm using Oracle? My connection string in the .config file references Oracle.DataAccess.Client, so I'm not sure how to fix this. Thanks!
May 22, 2007 at 3:11 AM
There is no database class for Oracle.DataAccess.Client that ships with Enterprise Library, so it will always use the GenericDatabase Class.

If you switch to using System.Data.OracleClient, it will use the OracleDatabase Class that ships with Enterprise Library and provide parameter discovery using OracleCommandBuilder.

The only other option is to create your own custom database class for Oracle.DataAccess.Client and then use the Provider Mappings to map your custom class to Oracle.DataAccess.Client.

In the past I know of a few people that built a database class for Oracle.DataAccess.Client. I would search this forum to find the posts. A class like that would be a great addition to the EntLib Contrib Project. A couple other database classes have been added there already that can be used as a template.

Regards,

Dave

___________________________

David Hayden
Microsoft MVP C#
May 22, 2007 at 3:52 PM
David,

Thanks for the reply. You are correct; we created a custom mapping and then used the provider Mappings element in our .config file. I noticed something strange though. I added the dataConfiguration element to the .config file and the error went away! Then, when I used the EntLib Config tool to add the Exception Handling block and some policies, my dataConfiguration element got over-written. Ouch. I didn't notice it had happened until I did a diff of my .config file versus what's in source control. Why would this happen?
Aug 15, 2014 at 5:41 AM
Hola coloca esto en tu APP config.
<providerMappings>
  <add databaseType="EntLibContrib.Data.OdpNet.OracleDatabase, EntLibContrib.Data.OdpNet, Version=5.0.505.0, Culture=neutral, PublicKeyToken=null" name="Oracle.DataAccess.Client"/>
</providerMappings>

Saludos