RE: Transaction Query
From: Tal Geva (Geva_at_discussions.microsoft.com)
Date: 06/29/04
- Next message: Mr. B: "Strange Interop.JRO Error off Server"
- Previous message: Rajesh Gutta: "Re: "Timeout expired. " when using Fill Method"
- In reply to: Jude_44: "Transaction Query"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 29 Jun 2004 09:11:50 -0700
I understand you want to write a vb/c# program and control the transacction.
so, here is some code in vb.net:
' declare the command - I used a stored proc but any insert\delete\update sql statement will do
Dim YourCmd As New System.Data.SqlClient.SqlCommand(stord_proc_name,yourdbConnection)
YourCmd .CommandType = CommandType.StoredProcedure
'declare the transaction object
Dim trans As System.Data.SqlClient.SqlTransaction
'fill parameters into the stored proc params
'set the transaction as a Specific db connection transaction
trans = yourdbConnection.BeginTransaction
YourCmd.Transaction = trans
' from here you can run the sql statement as many times as you need. when you want to commit:
trans.commit()
'or
trans.Rollback()
'and if you want to have another cycle, you need to repeat on those statements:
trans = yourdbConnection.BeginTransaction
YourCmd.Transaction = trans
Hope that helped
Tal
"Jude_44" wrote:
> Hi There
>
> I have been trying to establish how Transactions work from a .NET component.
> Basically, I have an operation I want to work in a transactional manner, but I would like to control this from within a function.
> How does Enterprise Services relate to COM+? Can I use Enterprise Services on a system without it having COM+ set up and my component installed there?
>
> So basically I need to something like the following within a method:
>
> Start a Transaction
> Perform a number of ADO calls to my SQL Server DB, with numerous connection objects and many changes to DB records. If theres a problem I want it to roll back all DB changes.
> End Transaction, and Commit if successful.
>
> Do I need to put it all within a single StoredProcedure in order to get Transactional support, or is there a way I can do it from VB.NET using EnterpriseServices, without having to rely on COM+ being installed and component registered within same COM+?
>
> Thanks for all your help!!
>
> Regards
> David Crone
- Next message: Mr. B: "Strange Interop.JRO Error off Server"
- Previous message: Rajesh Gutta: "Re: "Timeout expired. " when using Fill Method"
- In reply to: Jude_44: "Transaction Query"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|
|