connection bug

connection bug

Postby iwantit » Wed 27 Jul 2005 01:51

:cry:
when i test several conection drivers, i found that, the direct connection failed.
Code: Select all
      public void TestMsDriverConnection() {
         Console.WriteLine( "Microsoft Oracle Dirver" );
         string connectionString = "Data Source=ora9i;User Id=scott;Password=tiger";
         System.Data.OracleClient.OracleConnection connection = new System.Data.OracleClient.OracleConnection( connectionString );
         try {
            connection.Open();
            Console.WriteLine( "Data Source:\t{0}\nServer Version:\t{1}\nConnection State:\t{2}\nContainer:\t\t{3}\nSite:\t\t{4}\n\n", connection.DataSource, connection.ServerVersion, connection.State, connection.Container, connection.Site );
         } catch( Exception e ) {
            Console.WriteLine( e.Message );
            Console.WriteLine( e.StackTrace );
         } finally {
            connection.Close();
         }
      }

      public void TestOracleDriverConnection() {
         Console.WriteLine( "Oracle Dirver" );
         string connectionString = "Data Source=ora9i;User Id=scott;Password=tiger";
         Oracle.DataAccess.Client.OracleConnection connection = new Oracle.DataAccess.Client.OracleConnection( connectionString );
         try {
            connection.Open();
            Console.WriteLine( "Data Source:\t{0}\nServer Version:\t{1}\nConnection State:\t{2}\nContainer:\t\t{3}\nSite:\t\t{4}\n\n", connection.DataSource, connection.ServerVersion, connection.State, connection.Container, connection.Site );
         } catch( Exception e ) {
            Console.WriteLine( e.Message );
            Console.WriteLine( e.StackTrace );
         } finally {
            connection.Close();
         }
      }

      public void TestDirectConnection() {
         Console.WriteLine( "CoreLab Direct Driver" );
         string connectionString = "User Id=Scott;Password=tiger;Direct=true;Server=202.38.73.207;Port=1521;SID=ora9i";
         CoreLab.Oracle.OracleConnection connection = new CoreLab.Oracle.OracleConnection( connectionString );
         try {
            connection.Open();
            Console.WriteLine( "Data Source:\t{0}\nServer Version:\t{1}\nConnection State:\t{2}\nContainer:\t\t{3}\nSite:\t\t{4}\n\n", connection.DataSource, connection.ServerVersion, connection.State, connection.Container, connection.Site );
         } catch( Exception e ) {
            Console.WriteLine( e.Message );
            Console.WriteLine( e.StackTrace );
         } finally {
            connection.Close();
         }
      }

when i invoke these three methods, the last one, corelab's direct mode always failed.
if i invoke ms and corelab, or oracle and corelab, it succeed.
what's the reason?
iwantit
 

Postby Paul » Wed 27 Jul 2005 06:25

What error messge do you have? Which operationgenerates error?
Possibly you specified wrong "Sid" parameter. Please see OraDirect .Net documentation for more details.

Please take "Sid" from SERVICE_NAME parameter in tnsnames.ora. For example ConnectionString='Direct=True;Sid=orcl920'

ORA9i =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = SERVER)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = orcl920)
(FAILOVER_MODE = (TYPE = SELECT) (METHOD = BASIC) (RETRIES=100)
(DELAY=1))
)
)
Paul
 
Posts: 725
Joined: Thu 28 Oct 2004 14:06


Return to dotConnect for Oracle