By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,264 Members | 1,228 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,264 IT Pros & Developers. It's quick & easy.

2.0: design of database application with transactions

P: n/a
RAM
Hello,
(Sorry for my English...)
I am learning .NET 2.0 (C#, ASP.NET, ADO.NET etc.).
I need to write a database application (SQL Server) consisting of a number
of database transactions (like accounting system). Each of these
transactions has enty in menu, parameters screen (.aspx page), some logic
(probably implemented in code-behind), and results screen (could be
same.aspx page). I need a good design, some ideas of experienced
programmers.
My idea is the following: I will use web.sitemap to implement menu, and
X.aspx/X.aspx.cs to implement transactions. In Default.aspx I have a menu
using sitemap data source. In X.aspx.cs I have written

protected void Page_Load(...)
{
if (!IsPostBack)
{
...
transaction = connection.BeginTransaction("...");
}
}
protected void SaveButton_Click(...)
{
...
transaction.Commit();
}

One of my problems is that I don't know where to put Rollback. It is not
enough (I think) to create CancelButton because user could press Back button
in his/her browser :-(. I can put Rollback code into Default.aspx.cs
Page_Load (to be called when new menu option is executed), but I don't like
this idea.
Could you help me please to correctly design my application? (I must use
ASP.NET!)
Thank you.
/RAM/
Oct 1 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Usually you would create the transaction before you began doing any queries
or data manipulation. Then, as handle each item, check to see the result
that you're getting back from SQL Server and, if no errors are reported,
then move forward to the next item. If they're all OK then commit. If any of
them are false then you have to rollback the transaction immediately and
break out of the process since any further actionswould, of course, depend
on the success of the previous actions.

I often work with transactions in SQL Server stored procedures as well to
help ensure that things get handled efficiently and use the return parameter
of a stored procedure to let me know if things proceeded well (such as the
transaction was committed) or failed and was rolled back so I can then
rollback my asp.net transaction. I try not to use ASP.Net transactions
whenever I'm able though as they seem to have more overhead than using
built-in SQL Server transactions.

--
Hope this helps,
Mark Fitzpatrick
Former Microsoft FrontPage MVP 199?-2006
"RAM" <r_********@poczta.onet.plwrote in message
news:eg**************@TK2MSFTNGP05.phx.gbl...
Hello,
(Sorry for my English...)
I am learning .NET 2.0 (C#, ASP.NET, ADO.NET etc.).
I need to write a database application (SQL Server) consisting of a number
of database transactions (like accounting system). Each of these
transactions has enty in menu, parameters screen (.aspx page), some logic
(probably implemented in code-behind), and results screen (could be
same.aspx page). I need a good design, some ideas of experienced
programmers.
My idea is the following: I will use web.sitemap to implement menu, and
X.aspx/X.aspx.cs to implement transactions. In Default.aspx I have a menu
using sitemap data source. In X.aspx.cs I have written

protected void Page_Load(...)
{
if (!IsPostBack)
{
...
transaction = connection.BeginTransaction("...");
}
}
protected void SaveButton_Click(...)
{
...
transaction.Commit();
}

One of my problems is that I don't know where to put Rollback. It is not
enough (I think) to create CancelButton because user could press Back
button in his/her browser :-(. I can put Rollback code into
Default.aspx.cs Page_Load (to be called when new menu option is executed),
but I don't like this idea.
Could you help me please to correctly design my application? (I must use
ASP.NET!)
Thank you.
/RAM/

Oct 1 '06 #2

P: n/a
RAM
Thanks.

Użytkownik "Mark Fitzpatrick" <ma******@fitzme.comnapisał w wiadomo¶ci
news:%2****************@TK2MSFTNGP04.phx.gbl...
... If they're all OK then commit. If any of them are false then you have
to rollback the transaction immediately and break out of the process since
any further actionswould, of course, depend on the success of the previous
actions.
OK, but I nedd to give to the user opportunity to manually cancel work.
Where to put Rollback to be called also when user pressed Back browser's
button.
Please help. Thank you.
/RAM/
Oct 2 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.