Note that there are some explanatory texts on larger screens.

plurals
  1. POCannot Connect to Oracle in C#
    primarykey
    data
    text
    <p>I am trying to connect to Oracle in a 32-bit Console Application. I am getting the following erorr. The code (with the exception of host, username, and password change) is below. It is a simple two function project.</p> <p>Any help will be appreciated.</p> <p>I am using C# in Visual Studion 2010 Premium and Oracle 10g. I can connect to the database with Oracle SQL Developer with the information set in the connection string.</p> <hr> <p>---------------ToString-------------------------- --Oracle.DataAccess.Client.OracleException at Oracle.DataAccess.Client.OracleException.HandleErrorHelper(Int32 errCode, OracleConnection conn, IntPtr opsErrCtx, OpoSqlValCtx* pOpoSqlValCtx, Object src, String procedure) at Oracle.DataAccess.Client.OracleException.HandleError(Int32 errCode, Oracle Connection conn, IntPtr opsErrCtx, Object src) at Oracle.DataAccess.Client.OracleConnection.Open() at ConsoleApplication1.Program.GetConnection() in c:\users\maholt\documents\visual studio 2010\Projects\ConsoleApplication1\ConsoleApplication1\Program.cs:line 61</p> <h2>---------------Message---------------------------</h2> <hr> <pre><code>using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Data; using Oracle.DataAccess.Client; namespace ConsoleApplication1 { class Program { static OracleConnection conn; static void Main(string[] args) { OracleConnection connC = GetConnection(); conn = connC; simpleQuery(); Console.WriteLine("DONE"); } public static void simpleQuery() { OracleCommand cmd = new OracleCommand("select count(*) as total from console.client"); cmd.Connection = conn; cmd.CommandType = CommandType.Text; try { cmd.Connection.Open(); OracleDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { Console.WriteLine(Convert.ToString(reader["total"])); } } catch (Exception ex) { Console.WriteLine(ex.Message); } finally { cmd.Dispose(); } } public static OracleConnection GetConnection() { Oracle.DataAccess.Client.OracleConnection rtn = null; try { string connstr = "Data Source=//10.10.10.10:1521/PRD2_OLTP;User Id=user; Password=pass;"; rtn = new Oracle.DataAccess.Client.OracleConnection(connstr); if (rtn.State != System.Data.ConnectionState.Open) { rtn.Open(); } } catch (Exception ee) { Console.WriteLine("-------------------------------------------------"); Console.WriteLine("---------------ToString--------------------------"); Console.WriteLine("--" + ee.ToString()); Console.WriteLine("---------------Message---------------------------"); Console.WriteLine("--" + ee.Message); Console.WriteLine("-------------------------------------------------"); } return (rtn); } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload