C#SqlServer tryCatch [英] C# SqlServer tryCatch

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

问题描述

我有一个问题,我在sqlserver中有一个存储过程返回2个变量,在这个存储过程中我尝试了catched错误,所以对于C#这个程序永远不会退出并出错。

我可以使用

Hi, I have a question, I have a stored procedure in sqlserver the return 2 variables, in this stored procedure I try catched error, so for the C# this procedure never exit with error.
I can use

ERROR_NUMBER(),ERROR_SEVERITY(), ERROR_STATE(),ERROR_PROCEDURE(), ERROR_LINE(), ERROR_MESSAGE(); 



但我不知道我是否有同样的错误,所以我不知道管理这种情况的最佳方法是什么......





稍微提高一点:我确切知道如何在t-sql和C#中捕获错误,问题是如何传递我的所有信息通过C#捕获sql,例如,没有错误,SP返回2列,但是有错误它返回例如5列,我不知道先验


but I don''t know if I have same errors, so I don''t know what is the best way manage this situation...


A little improve: I know exactly how to catch error in t-sql and in C#, the problem is how to pass all the information that I catch in sql through C#, for example, without error the SP return 2 columns, but with error it return for example 5 columns, and I don''t know a priori

推荐答案

看看这些文章,你可以清楚地了解如何在sql中处理try catch。

article-handling-sql-server-error [ ^ ]

http: //msdn.microsoft.com/en-us/library/ms175976.aspx [ ^ ]
Have a look at these articles you may get clear picture how to handle a try catch in sql.
article-handling-sql-server-error[^]
http://msdn.microsoft.com/en-us/library/ms175976.aspx[^]


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

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