Oracle TNS Database The value for the key "data source" exceeds the limit of "128",

So, I have an Oracle database connection string, I copied it directly from the sql developer and then cut out the space.

I later add a username and password programmatically. The problem is when trying to open an SQLConnection object. I get an error message:

The value length for key 'data source' exceeds it limit of '128'

I really don't know much about oracle TNC compounds. I used this connection string because it worked in the wizard when I inserted it and tested the connection. And what you see is what Visual Studio generates after I inserted the TNS name.

Data Source="(DESCRIPTION=(ADDRESS= (PROTOCOL=TCP)
(HOST=qprd-scan.website.com)(PORT=3726))(CONNECT_DATA=(SERVER=dedicated 
(SERVICE_NAME=DBprd_developer)))";

This data source key already contains about 160 characters.

I watched this post on the MSDN forums.

, . , .

MSDN .

MSDN .

app.config,

+4
2

, , , , , OLE DB. , 128 .

, Oracle, . "" , - , # Oracle.

Oracle Managed Data Access. NuGet. :

  • > > ,
  • , " ",
  • Install-Package odp.net.managed
    

NuGet Oracle.ManagedDataAccess .

, using Oracle.ManagedDataAccess.Client, Oracle:

string connStr = "Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=<hostname>)(PORT=1521))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=<service_name>)));User Id=<user>;Password=<password>";
Console.WriteLine("Connection string has length " + connStr.Length);
using (var connection = new OracleConnection() { ConnectionString = connStr })
{
    connection.Open();
    OracleCommand command = new OracleCommand("SELECT * FROM DUAL", connection);
    using (OracleDataReader reader = command.ExecuteReader())
    {
        while (reader.Read())
        {
            Console.WriteLine(reader.GetString(0));
        }
    }
}
+2

app.config ODP.NET, ( EnterpriseLibrary5.0 System.Data.OracleClient ODP.NET Oracle.DataAccess.Client. publickey - , , - ). , , System.Data.OracleClient CLOB, 32kb.

<configSections>
  <section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=5.1.0.0, Culture=neutral, PublicKeyToken=4133a635bb2789db" requirePermission="true" />
</configSections>

<dataConfiguration defaultDatabase="DatabaseConnectionString" />
<connectionStrings>
    <add name="DatabaseConnectionString" connectionString="Data Source=TestDb;Persist Security Info=True;User ID=Usrname;Password=Pwd!;Max Pool Size=500;" providerName="Oracle.DataAccess.Client" />        
</connectionStrings>

TNS tnsnames.ora

TestDb=
  (DESCRIPTION=
    (ADDRESS=
      (PROTOCOL=TCP)
      (HOST=10.10.10.1)
      (PORT=1234)
    )
    (CONNECT_DATA=
      (SID=TestDb)
    )
  )

, app.config tnsnames.ora .

+1

All Articles