Transaction object

R

RP

I have a code like this:

==========================================
private void cmdProceed_Click(object sender, EventArgs e)
{
GenerateAll();
}
==========================================

I want to initialize transaction object just before GenerateAll(). The
GenerateAll procedure contains all the SQL statements, but I want to
set the transaction object before GenerateAll.
 
N

Nicholas Paldino [.NET/C# MVP]

RP,

So what's stopping you from doing this:

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

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

RP

But it is giving error:

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

What reference or initialization need to be done?
 

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