Using constructor with a connection string parameter fails for OracleConnection(string connstring)

Using constructor with a connection string parameter fails for OracleConnection(string connstring)

Postby ScottSEA » Fri 17 May 2013 22:51

When I try to pass in the connection string as a parameter to the constructor for OracleConnection(string conn) in my console application, I get an {"Input string was not in a correct format."} error:

Code: Select all
      static void Main(string[] args)
      {
         string username = "notMyRealUsername";
         string password = "notMyRealPassword";
         string server = "server.xx.boeing.com";
         int port = 1521;
         bool direct = true;
         string svcName = "funkytown.boeingdb";

         StringBuilder sb = new StringBuilder();
         sb.AppendFormat("User Id={0};", username)
           .AppendFormat("Password={0};", password)
           .AppendFormat("Server={0};", server)
           .AppendFormat("Port={0};", port)
           .AppendFormat("Direct={0};", direct)
           .AppendFormat("Service Name={0}", svcName);

         try
         {
             OracleConnection conn = new OracleConnection(sb.ToString());
         }
         catch (Exception)
         {
            throw;
         }
}

...and it appears to have something to do with the way that the OracleConnection object is parsing the connection string - trying to convert part of the connection string (I believe it is the Port number) to a string. If I instantiate the object this way:

Code: Select all
            OracleConnection conn = new OracleConnection()
            {
               UserId = username,
               Password = password,
               Server = server,
               Port = port,
               Direct = true,
               ServiceName = svcName
            };



It doesn't throw the error. The stack trace is :
Code: Select all
   at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal)
   at System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info)
   at System.Convert.ToInt32(String value)
   at Devart.Data.Oracle.cx.a()
   at Devart.Data.Oracle.b2.a(String A_0, Int32 A_1, String A_2, String A_3)
   at Devart.Data.Oracle.c7.a(b6 A_0, Boolean A_1)
   at Devart.Data.Oracle.c7.a(b6 A_0, o A_1)
   at Devart.Data.Oracle.OracleInternalConnection..ctor(b6 connectionOptions, OracleInternalConnection proxyConnection)
   at Devart.Data.Oracle.an.a(p A_0, Object A_1, DbConnectionBase A_2)
   at Devart.Common.DbConnectionFactory.a(DbConnectionPool A_0, p A_1, DbConnectionBase A_2)
   at Devart.Common.DbConnectionPool.a(DbConnectionBase A_0)
   at Devart.Common.DbConnectionPool.GetObject(DbConnectionBase owningConnection)
   at Devart.Common.DbConnectionFactory.b(DbConnectionBase A_0)
   at Devart.Common.DbConnectionClosed.Open(DbConnectionBase outerConnection)
   at Devart.Common.DbConnectionBase.Open()
   at Devart.Data.Oracle.OracleConnection.Open()
   at ConsoleApplication2.Program.Main(String[] args) in C:\Users\zp418c\Documents\Visual Studio 2010\Projects\ConsoleApplication2\ConsoleApplication2\Program.cs:line 58
   at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
   at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
   at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
   at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ThreadHelper.ThreadStart()


And here is the target information:
Image
(which for some reason isn't displaying, so here's the URL to that): http://imgur.com/znNV8sn
ScottSEA
 
Posts: 8
Joined: Thu 18 Apr 2013 21:23

Re: Using constructor with a connection string parameter fails for OracleConnection(string connstring)

Postby Shalex » Mon 20 May 2013 11:54

1. Try specifying IP address instead of ourserver.xx.boeing.com in the Server connection string parameter. Does it help?
2. The default value of the Port connection string parameter is 1521. You have specified this value explicitly. Please remove the Port parameter from your connection string for the test purpose. Does it make any difference?
3. Execute "SELECT * FROM v$version" on your Oracle server and send us the output.
Shalex
Devart Team
 
Posts: 7460
Joined: Thu 14 Aug 2008 12:44

Re: Using constructor with a connection string parameter fails for OracleConnection(string connstring)

Postby ScottSEA » Mon 20 May 2013 15:41

1. specifying the IP address did not help; same error: input string not in correct format.
2. removing the port specification did not make any difference; same error as above.
3. Our Oracle server version is 11.2.0.3.4
ScottSEA
 
Posts: 8
Joined: Thu 18 Apr 2013 21:23

Re: Using constructor with a connection string parameter fails for OracleConnection(string connstring)

Postby Shalex » Tue 21 May 2013 09:38

Shalex wrote:3. Execute "SELECT * FROM v$version" on your Oracle server and send us the output.

ScottSEA wrote:3. Our Oracle server version is 11.2.0.3.4

Please specify the full result set of the "SELECT * FROM v$version" query or send us its screenshot.
Shalex
Devart Team
 
Posts: 7460
Joined: Thu 14 Aug 2008 12:44

Re: Using constructor with a connection string parameter fails for OracleConnection(string connstring)

Postby ScottSEA » Tue 21 May 2013 16:11

SQL> SELECT * FROM v$version
2 ;

BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
PL/SQL Release 11.2.0.3.0 - Production
CORE 11.2.0.3.0 Production
TNS for Linux: Version 11.2.0.3.0 - Production
NLSRTL Version 11.2.0.3.0 - Production

SQL>

Please help me to understand why you need the database information for this issue. The error occurs upon instantiation of the OracleConnection object when you pass in a connection string to the constructor - completely independent and prior to attempting to open a connection to any database.
ScottSEA
 
Posts: 8
Joined: Thu 18 Apr 2013 21:23

Re: Using constructor with a connection string parameter fails for OracleConnection(string connstring)

Postby Shalex » Thu 23 May 2013 09:00

ScottSEA wrote:Please help me to understand why you need the database information for this issue.

We cannot reproduce the problem in our test environment.

If possible, please create a database user with limited privileges ("GRANT CREATE SESSION, CONNECT TO user_name") and give us the full connection string via contact form (http://www.devart.com/company/contact.html) to establish connection to your server so that we can reproduce the problem and debug our code.
Shalex
Devart Team
 
Posts: 7460
Joined: Thu 14 Aug 2008 12:44

Re: Using constructor with a connection string parameter fails for OracleConnection(string connstring)

Postby ScottSEA » Thu 23 May 2013 21:57

Sadly that is not possible; it is outside my area of responsibility. I have installed the oracle client and am able to connect thru that - I have no further time to dedicate to this issue.
ScottSEA
 
Posts: 8
Joined: Thu 18 Apr 2013 21:23

Re: Using constructor with a connection string parameter fails for OracleConnection(string connstring)

Postby Shalex » Tue 28 May 2013 10:56

We agree with you: the reason of the problem can be that Oracle server returns non-number when our provider reads the value of the port parameter. Currently we do not know a scenario which leads to such response. Is IPv6 used in your connection string or at your Oracle server?
Shalex
Devart Team
 
Posts: 7460
Joined: Thu 14 Aug 2008 12:44


Return to dotConnect for Oracle