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 |