OracleConnection causes an System.NullReferenceException
407989Dec 21 2006 — edited Feb 14 2008Environment: WinXP Pro
ODP.NET file version10.1.0.400
VS 2003 ver#7.1.6030
.NET ver# 1.1.4322 SP1
Microsoft Visual Basic .NET 69462-270-0000007-18225
Microsoft Visual C# .NET 69462-270-0000007-18225
I've tried to get a connection to Oracle via ODP but I get this error,'An unhandled exception of type 'System.NullReferenceException' occurred in oracle.dataaccess.dll
Additional information: Object reference not set to an instance of an object.', when I try to get the exception info/message. I've used VB.NET and C# hoping it would make a difference, I need help.
Thanks.
Sample Code:
try
{
OracleConnection oOracleConnection = new OracleConnection("user id=uuid;password=pwd;data source=dev");
oOracleConnection.Open();
if( oOracleConnection.State == ConnectionState.Open )
{
label1.Text = "Opened";
oOracleConnection.Close();
}
else
{
label1.Text = "Not open";
}
oOracleConnection.Dispose();
}
catch( Oracle.DataAccess.Client.OracleException ex )
{
label1.Text = ex.ToString();//or ex.Message;
}