dotConnect for Oracle Documentation
Devart.Data.Oracle Namespace / OracleInfoMessageEventArgs Class
Members Example

In This Topic
    OracleInfoMessageEventArgs Class
    In This Topic
    Provides data for the OracleConnection.InfoMessage event.
    Syntax
    'Declaration
     
    Public Class OracleInfoMessageEventArgs 
       Inherits System.EventArgs
    public class OracleInfoMessageEventArgs : System.EventArgs 
    Remarks
    The OracleConnection.InfoMessage event contains warning sent from the database.
    Example
    The following example demonstrates registering InfoMessage event handler that prints out the warning info.
    class OracleInfoMessage {
            public static void WarningPrinter(object src, OracleInfoMessageEventArgs args)
            {
                    Console.WriteLine("Source object is: " + src.GetType().Name);
                    Console.WriteLine("InfoMessageArgs.Message is " + args.Message);
                    Console.WriteLine("InfoMessageArgs.Source is " + args.Source);
            }
            static void Main()
            {
                    OracleConnection con = new OracleConnection("User Id=scott;" +
                            "Password=tiger;Data Source=ora1110;");
    
                    con.Open();
    
                    OracleCommand cmd = con.CreateCommand();
    
                    // Register to the InfoMessageHandler
                    cmd.Connection.InfoMessage +=
                            new OracleInfoMessageEventHandler(WarningPrinter);
    
                    cmd.CommandText = "CREATE OR REPLACE PACKAGE BODY PACKAGEWITHNOSPECIFICATION AS" +
                            "PROCEDURE GET_ALL_DEPTS (cur OUT SYS_REFCURSOR) AS" +
                            "BEGIN" +
                            " OPEN cur FOR SELECT * FROM DEPT;" +
                            "END;" +
                            "END PACKAGEWITHNOSPECIFICATION;";
    
                    // Execute the statement that produces a warning
                    cmd.ExecuteNonQuery();
    
                    // Clean up
                    cmd.Dispose();
                    con.Dispose();
            }
    }
    Module Module1
            Public Sub WarningPrinter(ByVal src As Object, ByVal args As OracleInfoMessageEventArgs)
                    Console.WriteLine("Source object is: " + src.GetType().Name)
                    Console.WriteLine("InfoMessageArgs.Message is " + args.Message)
                    Console.WriteLine("InfoMessageArgs.Source is " + args.Source)
            End Sub 'WarningPrinter
            Sub Main()
                    Dim con As New OracleConnection("User Id=scott;Password=tiger;Data Source=ora1110;")
                    con.Open()
                    Dim cmd As OracleCommand = con.CreateCommand()
                    ' Register to the InfoMessageHandler
                    AddHandler cmd.Connection.InfoMessage, _
                    New OracleInfoMessageEventHandler(AddressOf WarningPrinter)
                    'command.Connection.InfoMessage += New OracleInfoMessageEventHandler(WarningPrinter)
                    cmd.CommandText = "CREATE OR REPLACE PACKAGE BODY PACKAGEWITHNOSPECIFICATION AS" & _
                    "PROCEDURE GET_ALL_DEPTS (cur OUT SYS_REFCURSOR) AS" & _
                    "BEGIN" & _
                    " OPEN cur FOR SELECT * FROM DEPT;" & _
                    "END;" & _
                    "END PACKAGEWITHNOSPECIFICATION;"
                    ' Execute the statement that produces a warning
                    cmd.ExecuteNonQuery()
    
                    ' Clean up
                    cmd.Dispose()
                    con.Dispose()
            End Sub
    End Module
    Inheritance Hierarchy

    System.Object
       System.EventArgs
          Devart.Data.Oracle.OracleInfoMessageEventArgs

    Requirements

    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

    See Also