TransactionScope Error

R

RP

I tried following code but it generates error at line (using .....):

Error 23 The type or namespace name 'TransactionScope' could
not be
found (are you missing a using directive or an assembly reference?)

===
Code:
========================================

private void cmdProceed_Click(object sender, EventArgs e)
{
using (TransactionScope scope = new TransactionScope())
{
GenerateAll();

// Commit the transaction.
scope.Complete();
}

}
=================================================
 
J

Jon Skeet [C# MVP]

I tried following code but it generates error at line (using .....):

Error 23 The type or namespace name 'TransactionScope' could
not be found (are you missing a using directive or an assembly reference?)

Well, the error message is fairly clear: you're missing a using
directive or assembly reference. TransactionScope is in the
System.Transactions namespace, in the
System.Transactions.dll assembly.

Jon
 
R

RP

When I type System. , I cannot see anything like Transactions. It
does not appear in the list.
 
R

RP

I also want to know how is TransactionScope different from the old
SQLTransaction. Secondly, while using TransactionScope, how to
determine whether the transaction was successful or not.
 
J

Jon Skeet [C# MVP]

When I type System. , I cannot see anything like Transactions. It
does not appear in the list.

And that suggests that you haven't referenced the
System.Transactions.dll assembly.

Jon
 
J

Jon Skeet [C# MVP]

I also want to know how is TransactionScope different from the old
SQLTransaction.

Well it's not tied to SQL Server, to start with... it's a more general
transaction mechanism.
Secondly, while using TransactionScope, how to
determine whether the transaction was successful or not.

The docs aren't terribly clear, but it looks like you'll get a
TransactionInDoubtException if the commit fails.

Jon
 

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

Top