The exception that is generated when Oracle returns an error.
The following example generates a
OracleException due to a non-existing table, and then displays the exception.
public void ThrowOracleException()
{
string mySelectQuery = "SELECT * FROM NONEXISTINGTABLE";
OracleConnection myConnection =
new OracleConnection(
"User Id=Scott;Password=tiger;Data Source=Ora;");
OracleCommand myCommand = new OracleCommand(mySelectQuery,myConnection);
try
{
myCommand.Connection.Open();
}
catch (OracleException myException)
{
MessageBox.Show("Message: " + myException.Message + "\n");
}
}
Public Sub ThrowOracleException()
Dim mySelectQuery As String = "SELECT * FROM NONEXISTINGTABLE"
Dim myConnection As New OracleConnection( _
"User Id=Scott;Password=tiger;Data Source=Ora;")
Dim myCommand As New OracleCommand(mySelectQuery, myConnection)
Try
myCommand.Connection.Open()
Catch myException As OracleException
MessageBox.Show("Message: " + myException.Message + ControlChars.Cr)
End Try
End Sub
Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2