에서 호출합니다. SQL Server에 저장 프로 시저를 사용하고 있습니다. C#으로 작성된 여러 저장 프로 시저 호출이 있습니다. 거래 내에서 포장하고 싶습니다.저장 프로 시저 호출에 대한 트랜잭션을 C#
//Begin Transaction here
sp1Call();
sp2Call();
sp3Call();
//Commit here
//Rollback if failed
어떤 방법이 있습니까?
업데이트 : 엔터프라이즈 라이브러리를 사용하고 있습니다. sp1Call()에 예 : 당신은 SqlTransaction
을 체크 아웃 할 수 있습니다
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
Enterprise 라이브러리를 사용하고 있습니다. 업데이트를 참조하십시오. – Naor