2.0: transaction on ASP.NET page

R

RAM

Hello,
I am learning .NET. I am writing database application which contains some
operations accessible from ASP.NET menu. This operations should be separate
transactions.
I wrote:

public partial class PZ : System.Web.UI.Page
{
bool Commited;
protected void Page_Load(...)
{
if (!IsPostBack)
{
Cache["Transaction"] = Admin.Conn.BeginTransaction["PZ"];
Commited = false
}
}
protected void Save_Click(...)
{
SqlTransaction t = (SqlTransaction)Cache["Transaction"];
if (t != null)
t.Commit();
Commited = true;
}
}

I don't know where to put Rollback code. I cannot do it in Page_Unload
because page is reloaded because of list box control.
Could you give me some suggestion how to do it?
Thank you
/RAM/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top