我的类中有一个方法执行两个存储过程并将数据插入三个表中。在这种情况下如何处理交易?
例如:
public class InsertClass
{
public void AddData()
{
try
{
Execute Sp1;
Execute Sp2;
}
catch (Exception ex)
{
throw ex;
}
}
}
两个SP都用于插入。
答案 0 :(得分:2)
试试这个:
WKWebView *wb = [WKWebView new];
[wb loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://file8a445fb7811e.iamh5.cn/v3/idea/u5UfsotV?suid=ohAJ7wa8J4S-rj0SFOVmrDhOBotM&from=singlemessage"]]];
答案 1 :(得分:-1)
试试这段代码:
connection.Open();
SqlTransaction transaction = connection.BeginTransaction();
try
{
Execute Sp1;
Execute Sp2;
}
catch (Exception)
{
transaction.Rollback();
connection.Close();
}
transaction.Commit();