Oracle ODP.Net Dynamic Connection

Posts   
 
    
ronnieb
User
Posts: 21
Joined: 23-Sep-2010
# Posted on: 23-Sep-2010 16:56:01   

Hello,

I'm a new trial user and I need to be able to dynamically create the connection string at runtime as well as change the schema name.

I've created a test console app and I'm trying to execute a simple query with the following code:

var filter = new RelationPredicateBucket(
    MasterFields.State == "VA");
var accounts = new EntityCollection<MasterEntity>();
using (var adapter = new DataAccessAdapter())
{
    adapter.ConnectionString = "data source=VPR1;user id=demo;password=*******;persist security info=false;";
    adapter.FetchEntityCollection(accounts, filter);
}
Console.WriteLine("Number of entities fetched: {0}", accounts.Count);

On the FetchEntityCollection, I get an exception: ... InnerException: System.ArgumentException Message=Unable to find the requested .Net Framework Data Provider. It may not be installed. ...

I'm running on XP x64 and have installed the win64_11gR2_client Oracle drivers and can connect successfully with the designer.

What am I missing?

Thanks,

Ronnie

MTrinder
User
Posts: 1461
Joined: 08-Oct-2008
# Posted on: 23-Sep-2010 21:28:37   

http://www.goffsoft.com/post/Diagnostics-x64-ODPnet-and-Unable-to-find-Data-Provider.aspx

seems to cover a similar issue.

If you create a test app using just ADO.NET (so no LLBLGen code) do you get the same issue ?

Matt

ronnieb
User
Posts: 21
Joined: 23-Sep-2010
# Posted on: 24-Sep-2010 03:22:34   

No, it works just fine with this code:

var connectionString = "data source=QSM.VPR1;user id=demo;password=******;persist security info=false;";
var conn = new OracleConnection(connectionString);
conn.Open();
var adapter = new OracleDataAdapter();
adapter.SelectCommand = new OracleCommand(
    "SELECT * FROM MASTER WHERE STATE = 'VA'", conn); 
var dataSet = new DataSet("masterDataSet");
adapter.Fill(dataSet, "Accounts");

-Ronnie

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 24-Sep-2010 07:00:27   

We will try to reproduce it.

What LLBLGen version and runtimelibrary are you using?

Does the problem persist if you pass the connection string into the adapter constructor?

David Elizondo | LLBLGen Support Team
ronnieb
User
Posts: 21
Joined: 23-Sep-2010
# Posted on: 24-Sep-2010 13:22:26   

I'm using version 3.0 Final - TRIAL release on September 8th, 2010.

The assembly that gets loaded:

SD.LLBLGen.Pro.ORMSupportClasses.NET20, Version=3.0.0.0, Culture=neutral, Public KeyToken=ca73b74ba4e3ff27

It doesn't make a difference if I put the connection string in the constructor, same error.

Here's the full exception:

System.TypeInitializationException was unhandled Message=The type initializer for 'SD.LLBLGen.Pro.DQE.Oracle.DynamicQueryEngine' threw an exception. Source=SD.LLBLGen.Pro.DQE.OracleODPNet.NET20 TypeName=SD.LLBLGen.Pro.DQE.Oracle.DynamicQueryEngine StackTrace: at SD.LLBLGen.Pro.DQE.Oracle.DynamicQueryEngine..ctor() at Base.Model.DatabaseSpecific.DataAccessAdapter.CreateDynamicQueryEngine() in C:\Projects\LLBLGen\Base.Model\DatabaseSpecific\DataAccessAdapter.cs:line 108 at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.CreateSelectDQ(IEntityFields2 fieldsToFetch, IFieldPersistenceInfo[] persistenceInfoObjects, IPredicateExpression filter, Int64 maxNumberOfItemsToReturn, ISortExpression sortClauses, IRelationCollection relationsToWalk, Boolean allowDuplicates, IGroupByCollection groupByClause, Int32 pageNumber, Int32 pageSize) in c:\Myprojects\VS.NET Projects\LLBLGen Pro v3.0\Frameworks\LLBLGen Pro\RuntimeLibraries\ORMSupportClasses\AdapterSpecific\DataAccessAdapterBase.cs:line 4439 at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.FetchEntityCollectionInternal(IEntityCollection2 collectionToFill, IRelationPredicateBucket& filterBucket, Int32 maxNumberOfItemsToReturn, ISortExpression sortClauses, ExcludeIncludeFieldsList excludedIncludedFields, Int32 pageNumber, Int32 pageSize) in c:\Myprojects\VS.NET Projects\LLBLGen Pro v3.0\Frameworks\LLBLGen Pro\RuntimeLibraries\ORMSupportClasses\AdapterSpecific\DataAccessAdapterBase.cs:line 4563 at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.FetchEntityCollection(IEntityCollection2 collectionToFill, IRelationPredicateBucket filterBucket, Int32 maxNumberOfItemsToReturn, ISortExpression sortClauses, IPrefetchPath2 prefetchPath, ExcludeIncludeFieldsList excludedIncludedFields, Int32 pageNumber, Int32 pageSize) in c:\Myprojects\VS.NET Projects\LLBLGen Pro v3.0\Frameworks\LLBLGen Pro\RuntimeLibraries\ORMSupportClasses\AdapterSpecific\DataAccessAdapterBase.cs:line 2467 at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.FetchEntityCollection(IEntityCollection2 collectionToFill, IRelationPredicateBucket filterBucket) in c:\Myprojects\VS.NET Projects\LLBLGen Pro v3.0\Frameworks\LLBLGen Pro\RuntimeLibraries\ORMSupportClasses\AdapterSpecific\DataAccessAdapterBase.cs:line 2276 at DemoConsole.Program.Main(String[] args) in C:\Projects\LLBLGen\DemoConsole\DemoConsole\Program.cs:line 38 at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args) at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.ThreadHelper.ThreadStart() InnerException: System.ArgumentException Message=Unable to find the requested .Net Framework Data Provider. It may not be installed. Source=System.Data StackTrace: at System.Data.Common.DbProviderFactories.GetFactory(String providerInvariantName) at SD.LLBLGen.Pro.ORMSupportClasses.DbProviderFactoryInfo.get_FactoryToUse() in c:\Myprojects\VS.NET Projects\LLBLGen Pro v3.0\Frameworks\LLBLGen Pro\RuntimeLibraries\ORMSupportClasses\Persistence\DbProviderFactoryInfo.cs:line 181 at SD.LLBLGen.Pro.ORMSupportClasses.DbProviderFactoryInfo.get_FactoryForReflection() in c:\Myprojects\VS.NET Projects\LLBLGen Pro v3.0\Frameworks\LLBLGen Pro\RuntimeLibraries\ORMSupportClasses\Persistence\DbProviderFactoryInfo.cs:line 214 at SD.LLBLGen.Pro.ORMSupportClasses.DbProviderFactoryInfo.InitializeEnumTypeCache() in c:\Myprojects\VS.NET Projects\LLBLGen Pro v3.0\Frameworks\LLBLGen Pro\RuntimeLibraries\ORMSupportClasses\Persistence\DbProviderFactoryInfo.cs:line 135 at SD.LLBLGen.Pro.ORMSupportClasses.DbProviderFactoryInfo.SetDbProviderFactoryParameterData(String dbProviderFactoryInvariantName, String dbProviderSpecificEnumTypeName, String dbProviderSpecificEnumTypePropertyName) in c:\Myprojects\VS.NET Projects\LLBLGen Pro v3.0\Frameworks\LLBLGen Pro\RuntimeLibraries\ORMSupportClasses\Persistence\DbProviderFactoryInfo.cs:line 92 at SD.LLBLGen.Pro.DQE.Oracle.OracleSpecificCreator.SetDbProviderFactoryParameterData(String dbProviderFactoryInvariantName, String dbProviderSpecificEnumTypeName, String dbProviderSpecificEnumTypePropertyName) in c:\Myprojects\VS.NET Projects\LLBLGen Pro v3.0\Frameworks\LLBLGen Pro\RuntimeLibraries\OracleDQE\OracleSpecificCreator.cs:line 99 at SD.LLBLGen.Pro.DQE.Oracle.DynamicQueryEngine..cctor() in c:\Myprojects\VS.NET Projects\LLBLGen Pro v3.0\Frameworks\LLBLGen Pro\RuntimeLibraries\OracleDQE\DynamicQueryEngine.cs:line 96 InnerException:

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 26-Sep-2010 12:20:10   

Now v3 works with DBProviderFactories. It seems LLBLGen runtime can't find the provider. If that is true, exception should throw even if you don't specify a connection string, right?

In the machine.config file of your .NET version (if you run the .net 4 runner, you should look in the machine.config file of .net 4, otherwise the .net 2 one), in the dbproviderfactories section, is there a line for Oracle.DataAccess? If not, no dbproviderfactory is registered and therefore the driver can't access / find it.

David Elizondo | LLBLGen Support Team
ronnieb
User
Posts: 21
Joined: 23-Sep-2010
# Posted on: 26-Sep-2010 23:03:52   

That did the trick!

I added the following line last week into the machine.config in the Framework folder, but failed to add it the config file in the Framework64 folder:

<add name="Oracle Data Provider for .NET" invariant="Oracle.DataAccess.Client" description="Oracle Data Provider for .NET" type="Oracle.DataAccess.Client.OracleClientFactory, Oracle.DataAccess, Version=2.112.1.0, Culture=neutral, PublicKeyToken=89b483f429c47342" />

Once I added it there, I was able to run my query.

Thanks,

Ronnie