I've a little dilemma that comes out yesterday at work...
We're building an enterprise application that extensively use a database (SQL Server), and some actions on the database are performed with the use of transactions.
To perform an action on the database we always use stored procedure and the question that comes in my mind yesterday was this:
to perform a transaction, what is better? Using a stored procedure that performs the actions on the database in a transaction (something like this):
begin tran T
-- Action 1
-- Action 2
-- Action 3
commit tran T
or starting the transaction via my code (something like this):
Dim Transaction As SqlTransaction
Dim Command As SqlCommand
Connection.Open()
Try
Transaction = Connection.BeginTransaction()
Command = New SqlCommand(...........,Connection, Transaction) 'Perform Action 1
Command = New SqlCommand(...........,Connection, Transaction) 'Perform Action 2
Command = New SqlCommand(...........,Connection, Transaction) 'Perform Action 3
Transaction.Commit()
Catch
Transaction.Rollback()
Throw
Finally
Connection.Close()
End Try
What do you think? Advantages or disadvantages of the 2 methods?
The great idea that comes from the mind of Robert Green is now reaady... on his blog he has announced the availability of his Visual Basic .NET Power Pack.
What is it? It's a VB team community project and consists of seven custom controls written in Visual Basic .NET 2003. The controls provide enhanced user interface elements and enable you to create more interesting and more colorful client based applications.
The Power Pack controls are:
- BlendPanel: provides a gradiant fill background you can use on forms. Set the start color, the end color and the direction for the gradiant.
- Notification Window: provides a way to display messages using “toast“ like Windows Messenger uses.
- UtilityToolbar: Provides a graphical toolbar that looks and behaves very much like the one in Internet Explorer.
- ImageButton: Provides a button that displays images on a transparent background. So your button displays just the image and not the whole rectangle with the image.
- TaskFrame: A container for TaskPanes. This control looks and behaves like the TaskPane in Word 2003 or Excel 2003. The TaskPanes are collapsable windows that can contain any control.
- FolderViewer: Displays a hierarchy of folders on a computer.
- FileViewer: Displays the files in a specfied folder.
This Power Pack is ready to be downloaded from the VB Power Pack Workspace on GotDotNet. The controls come with the complete source code, as well as an article and short sample.
Great work Robert! All the comunity will apreciate the product of your last month of work. 