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

查看:94
本文介绍了在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.

如果RAISERROR的严重程度在10和16之间被认为是一个错误,你的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天全站免登陆