Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / October 2007

Tip: Looking for answers? Try searching our database.

TransactionScope Error

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
RP - 12 Oct 2007 08:15 GMT
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();
   }

}
=================================================
Jon Skeet [C# MVP] - 12 Oct 2007 08:21 GMT
> 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
RP - 12 Oct 2007 08:32 GMT
When I type System.   , I cannot see anything like Transactions. It
does not appear in the list.

> > I tried following code but it generates error at line (using .....):
>
[quoted text clipped - 7 lines]
>
> Jon
Jon Skeet [C# MVP] - 12 Oct 2007 09:58 GMT
> 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
RP - 12 Oct 2007 08:41 GMT
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.
Jon Skeet [C# MVP] - 12 Oct 2007 10:01 GMT
> 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

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.