我正在使用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