在我的以下C#代码上建议一些解决方案 [英] Suggest some solution on my following C# code
本文介绍了在我的以下C#代码上建议一些解决方案的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
请建议解决以下问题。我在代码中有3个SP(存储过程)。如果其中任何一个失败,我希望将错误产生到输出。回滚之前我想知道哪个事务失败了,发生了什么。
注意:我们不能对SQL服务器的SP进行任何更改,只能在C#代码中提供一些功能。
代码是:
尝试
{
SP1,A输出
SP2,B输出
SP3,C输出
}
catch (Exception ex)
{
// exception
}
谢谢,
AVINCODE
解决方案
使用.net提供的交易查看链接以供参考
http://stackoverflow.com/questions/224689/transactions-in-net [ ^ ]
Hi,
Kindly suggest solution on following problem. I have 3 SP(Stored Procedures) in code. If any of these fail, I want the error to be produced to the output. I want to know which transaction failed and what happened, before roll back.
Note: We can't do any changes in SQL server's SP, have to provide some functionality in C# code only.
Code is :
try
{
SP1 with A output
SP2 with B output
SP3 with C output
}
catch (Exception ex)
{
//exception
}
Thanks,
AVINCODE
解决方案
Use transaction provided by .net see the link for reference
http://stackoverflow.com/questions/224689/transactions-in-net[^]
这篇关于在我的以下C#代码上建议一些解决方案的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文