mpultz
July 12th, 2001, 05:59 PM
I'm trying to connect to a Oracle database (ver. 8.1.5) from C# (beta 2). See the code below. My problem is that I some times do connect and some times I do not. In the latter case I get the following exception:
Unhandled Exception: System.Data.OleDb.OleDbException: Oracle error occurred, but
error message could not be retrieved from Oracle.
at System.Data.OleDb.OleDbConnection.ProcessResults(Int32 hr)
at System.Data.OleDb.OleDbConnection.InitializeProvider()
at System.Data.OleDb.OleDbConnection.Open()
at ADOTest.Main(String[] args)
I can't figure out why the exception occurs occasionaly but can it be my connection string that is not optimal?
Any help is appreciated.
Regards
using System;
using System.Data.OleDb;
class ADOTest
{
public static void Main(string[] args)
{
const string connStr = "Provider=MSDAORA;Database=pultz;User ID=scott;Password=tiger";
OleDbConnection myConn = new OleDbConnection(connStr);
string myQuery = "SELECT * FROM EMP";
OleDbCommand myOleDbCommand = new OleDbCommand(myQuery);
myOleDbCommand.Connection = myConn;
myConn.Open();
Console.WriteLine("Server version: " + myConn.ServerVersion
+ "\nState: " + myConn.State.ToString());
OleDbDataReader rset = myOleDbCommand.ExecuteReader();
int i = 0;
while (rset.Read())
++i;
Console.WriteLine(i + " rows selected");
myConn.Close();
}
}
Unhandled Exception: System.Data.OleDb.OleDbException: Oracle error occurred, but
error message could not be retrieved from Oracle.
at System.Data.OleDb.OleDbConnection.ProcessResults(Int32 hr)
at System.Data.OleDb.OleDbConnection.InitializeProvider()
at System.Data.OleDb.OleDbConnection.Open()
at ADOTest.Main(String[] args)
I can't figure out why the exception occurs occasionaly but can it be my connection string that is not optimal?
Any help is appreciated.
Regards
using System;
using System.Data.OleDb;
class ADOTest
{
public static void Main(string[] args)
{
const string connStr = "Provider=MSDAORA;Database=pultz;User ID=scott;Password=tiger";
OleDbConnection myConn = new OleDbConnection(connStr);
string myQuery = "SELECT * FROM EMP";
OleDbCommand myOleDbCommand = new OleDbCommand(myQuery);
myOleDbCommand.Connection = myConn;
myConn.Open();
Console.WriteLine("Server version: " + myConn.ServerVersion
+ "\nState: " + myConn.State.ToString());
OleDbDataReader rset = myOleDbCommand.ExecuteReader();
int i = 0;
while (rset.Read())
++i;
Console.WriteLine(i + " rows selected");
myConn.Close();
}
}