ptn77
ptn77

Reputation: 627

Oracle.ManagedDataAccess.Client in EntLib 4.1 error "Connection string is not well-formed"

I use the Oracle.ManagedDataAccess.Client and installed the Oracle.ManagedDataAccess through Nuget. Here's the app.config configuration:

 <configSections>
    <section name="oracle.manageddataaccess.client" type="OracleInternal.Common.ODPMSectionHandler, Oracle.ManagedDataAccess, Version=4.122.18.3, Culture=neutral, PublicKeyToken=89b483f429c47342"/>
    </configSections>

    <dataConfiguration>
    <providerMappings>
      <add name="Oracle.ManagedDataAccess.Client" databaseType="Oracle.ManagedDataAccess.Client.OracleClientFactory, Oracle.ManagedDataAccess, Version=4.122.18.3, Culture=neutral, PublicKeyToken=89b483f429c47342"/>
    </providerMappings>
  </dataConfiguration>

    <connectionStrings>
    <add name="Oracle" connectionString="Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=ORCL)));User Id=user;Password=pass;Integrated Security=no"
      providerName="Oracle.ManagedDataAccess.Client" />
    </connectionStrings>

Here's the C# code:

 DbProviderFactory providerFactory = DbProviderFactories.GetFactory("Oracle.ManagedDataAccess.Client");
Database database = new Microsoft.Practices.EnterpriseLibrary.Data.GenericDatabase("Oracle", providerFactory);
 OracleCommand commandObj = null;

using (commandObj = (OracleCommand)database.GetStoredProcCommand(spName))
{
    commandObj.CommandType = CommandType.StoredProcedure;
}

I'm stuck on the connection string, as it's failing with the error: "Connection string is not well-formed"

Upvotes: 0

Views: 909

Answers (1)

ptn77
ptn77

Reputation: 627

When calling Microsoft.Practices.EnterpriseLibrary.Data.GenericDatabase("Oracle", providerFactory); instead of passing the config key name = "Oracle", I had to pass in the whole connection string.

Upvotes: 1

Related Questions