简体   繁体   English

AseConnection InfoMessage 将打印语句作为错误消息返回

[英]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.我在 Sybase ASE 15.7 中工作,我正在尝试从 T-SQL 返回消息,如下所示。 I'm using the AseConnection.InfoMessage event handler to capture messages from the database.我正在使用 AseConnection.InfoMessage 事件处理程序从数据库中捕获消息。 It is working fine but it is also returning the print statement as an AseError message.它工作正常,但它也将打印语句作为 AseError 消息返回。 Why is this happening and how can I correct it?为什么会发生这种情况,我该如何纠正?

Console Output:控制台输出:

Log: 12522 rows in SomeTable日志:SomeTable 中有 12522 行

AseError Log: 12522 rows in SomeTable AseError 日志:SomeTable 中有 12522 行

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 .所有消息、错误和信息共享一个数据结构,将消息描述为AseError

I work on an open source project that produces a .NET Core version of the AseClient .我在一个开源项目上工作,该项目生成了AseClient.NET Core 版本 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.该项目的目标之一是成为 SAP/Sybase 驱动程序的直接替代品——因此我们复制了上述设计决策——尽管它很奇怪。

A severity >10 is considered an error.严重性>10被视为错误。 Otherwise it is considered informational.否则,它被认为是信息性的。 If it helps you make sense of it, here is our code for interpreting the server messages: MessageTokenHandler.cs如果它帮助你理解它,这里是我们解释服务器消息的代码: MessageTokenHandler.cs

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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