Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error when using OracleConnection.Open() ORA-00303: Network Library: Name-Value syntax error ODP.NET managed dll

I am getting this error when i hit the source.Open(); line of code and I cannot figure out why. I was using the unmanaged dll and I am trying to upgrade to the version Oracle.ManagedDataAccess.dll 64-bit and my project is using .NET framework 4. The TNS string is working in the production tnsnames.ora file(Ive replaced various element name and values). From the error it seems like something should be obviously wrong but I just cant get it to work.

TNS in app.config:

<oracle.manageddataaccess.client>
<version number="*">
  <dataSources>
    <dataSource alias="ABC_DEF_GH" descriptor="ABC_DEF_GH =    (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = server.company.com)(PORT = 11111))(CONNECT_DATA = (SERVICE_NAME = ABC_DEF_GH.company.com)))"/>
  </dataSources>
</version>

</oracle.manageddataaccess.client>

Code snippet:

using (OracleConnection source = new OracleConnection("UserId=xxxxx;Password=xxxxxx;DataSource=ABC_DEF_GH;"))
{

OracleCommand command = new OracleCommand(transferConfig.QueryLogic + WhereClause, source);
//The time (in seconds) to wait for the command to execute. The default is 30 seconds.
command.CommandTimeout = transferConfig.SourceCommandTimeout;
// command.Connection.ConnectionTimeout is set in the connection string only
source.Open();
//...
}

Error: ORA-00303: Network Library: Name-Value syntax error

like image 831
user2848442 Avatar asked Oct 07 '14 17:10

user2848442


1 Answers

You should follow the following format for your connection string:

SERVER=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=MyHost)(PORT=MyPort))(CONNECT_DATA=(SERVICE_NAME=MyOracleSID)));uid=myUsername;pwd=myPassword;

Check with this format please, the error is related to using an incorrect format for the connection string.

like image 117
Rex Avatar answered Nov 08 '22 03:11

Rex