none
ADO.Net ODBCConnection is not returning InfoMessage event!! RRS feed

  • Question

  • I am using ODBCConnection and trying to get back InfoMessage .. the sql anywhere driver is odbc11.dll.  I am not getting the InfoMessage even raised!! Can someone please help!

    using System.Data.Odbc;
    using System;
    namespace ConsoleApplication2
    {
        class Program
        {
            static void Main(string[] args)
            {
                using (OdbcConnection con = new OdbcConnection("DRIVER={SQL Anywhere 11};Commlinks=TCPIP{host=***.net:3053};SERVERNAME=***;DATABASEName=***;UID=dba;PASSWORD=**;Integrated=NO"))
                {
                    con.InfoMessage += InfoMessage_Event;
                    con.Open();
                    using (OdbcCommand com = new OdbcCommand("Message 'asdfasdgdag' to client", con))
                    {
                        OdbcDataReader r = com.ExecuteReader();
                    }
                }
            }
            private static void InfoMessage_Event(object sender, OdbcInfoMessageEventArgs e)
            {
                Console.WriteLine(e.Message);
            }
        }
    }

    Thursday, May 17, 2012 12:11 PM

Answers

  • I think you need to create a new instance of OdbcInfoMessageEventHandler:

    con.InfoMessage += new OdbcInfoMessageEventHandler(InfoMessage_Event);


    Paul ~~~~ Microsoft MVP (Visual Basic)

    Thursday, May 17, 2012 4:15 PM