在 C# 中存储 SqlServer 的 raiserror 消息 [英] Storing SqlServer's raiserror message in C#

查看:35
本文介绍了在 C# 中存储 SqlServer 的 raiserror 消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在 C# 中存储 SQLSERVER 的 raiserror 消息?

How can I store SQLSERVER's raiserror message in C# ?

推荐答案

这取决于 您的 RAISERROR 的严重性.严重性 1-10 被视为信息消息,不会中断 C# 客户端的流程,即.他们不会抛出异常.这些信息消息将触发 InfoMessage连接上的事件.

It depends on the severity of your RAISERROR. Severities 1-10 are considered information messages and do not break the flow of your C# client, ie. they don't throw exception. These information messages will trigger the InfoMessage event on your connection.

如果严重性在 10 到 16 之间的 RAISERROR 被视为错误,并且您的 SqlCommand.Execute 将抛出您可以捕获的异常.

If you RAISERROR with severity between 10 and 16 is considered an error and your SqlCommand.Execute will throw and exception you can catch.

17 以上的严重性不适合您,它们仅供引擎用于指示可能使数据库脱机或关闭实例的严重问题.在技​​术上不可能提出严重性高于 25 的错误,您的严重性为 100 的示例只是愚蠢.

Severities above 17 are not for you to play with, they are only to be used by the engine to indicate severe problems that may take the database offline or shutdown the instance. Is not technically possible to raise errors with severity above 25, your example with severity 100 is just silliness.

这篇关于在 C# 中存储 SqlServer 的 raiserror 消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆