我正在使用SQL Server中的存储过程。 我有几个用c#编写的存储过程调用。我想在交易中包装它们:创建事务到存储过程调用c#
//Begin Transaction here
sp1Call();
sp2Call();
sp3Call();
//Commit here
//Rollback if failed
有没有办法做到这一点?
更新: 我正在使用企业库。例如sp1Call():
public static void sp1Call(string itemName)
{
DbCommand command = db.GetStoredProcCommand("dbo.sp1_insertItem");
db.AddInParameter(command, "@item_name", DbType.String, itemName);
db.ExecuteNonQuery(command);
}
你怎么称呼你的程序?你使用什么客户端API? – alexn 2011-01-22 17:14:36
我正在使用企业库。请参阅更新。 – Naor 2011-01-22 17:25:27