简体   繁体   中英

AseConnection InfoMessage returning print statement as an error message

I am working in Sybase ASE 15.7 and I am trying to return messages from a T-SQL as shown below. I'm using the AseConnection.InfoMessage event handler to capture messages from the database. It is working fine but it is also returning the print statement as an AseError message. Why is this happening and how can I correct it?

Console Output:

Log: 12522 rows in SomeTable

AseError Log: 12522 rows in SomeTable

string sql= @"set nocount on
              declare @rowcount    int                            
              select  @rowcount = count(*) from SomeTable
              print   'Log: %1! rows in SomeTable', @rowcount";

using (var conn = GetOpenConnection(connectionString))
{
   conn.InfoMessage += (s,e) =>
   {
      Console.WriteLine(e.Message);
      foreach (var error in e.Errors)
         Console.WriteLine(error.ToString())
   };
   using (var command = new AseCommand(sql, conn))
   {
      command.ExecuteNonQuery();
   }
}

It is just a really bizarre design decision by the authors of the driver. All messages, errors and info, share a data structure that describes the message as an AseError .

I work on an open source project that produces a .NET Core version of the AseClient . One of the goals of that project is to be a drop-in replacement for the driver from SAP/Sybase - and for that reason we have replicated the above design decision - as weird as it is.

A severity >10 is considered an error. Otherwise it is considered informational. If it helps you make sense of it, here is our code for interpreting the server messages: MessageTokenHandler.cs

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM