0

Hi I have a generator which made some automated code (creating all the get, set, etc) for me structured by a Database, in this code there is a piece of code that is as follows:

SqlTransaction transaction = TransactionManager.GetTransaction();

I have added the reference and imported using System.Transactions; at the beginning of the file manually because the code generator never did this. Once imported, this removed the TransactionManager error I was getting but now I am receiving an error on .GetTransaction(); from what I have researched there is no such method in the TransactionManager.
Does anyone have any clue as to what should be in place of this code (the generator has some code which has to be replaced due to errors, my guess is this is one of those cases...). Any suggestions would be appreciated! Thanks in advance!

Kris van der Mast
  • 16,343
  • 8
  • 39
  • 61
Orlando
  • 935
  • 2
  • 20
  • 42

3 Answers3

2

This answer presumes that the generator you are using was built in house and you are modifying it now - if it was an external code generator then you should check the manual for it around what references you need.

The TransactionManager class in System.Transactions does't actually create or enlist in transactions for you. It simply provides information about the current transactions. From MSDN:

This class contains static properties and methods used to obtain information about the default transaction options.

Instead I think you want either:

Googling TransactionManager it appears that people commonly write their own classes with this name which do things like offer a GetTransaction() method - possible this is why the generator has this name?

David Hall
  • 32,624
  • 10
  • 90
  • 127
  • It is an in house application but not made by my project team was given to us to use but the creator is on vacation now and there is no manual. We're not trying to work ont he actual generator we just needed to use it to simplify creating all the Data Types for the Database. – Orlando Apr 21 '11 at 13:10
  • @Lord-Link in that case I think you need to find what namespace the TransactionManger from your generator is in, and include that, because it isn't the TransactionManager from System.Transactions – David Hall Apr 21 '11 at 13:12
0

Adding just some Transaction namespaces should not help. You'll probably need some base DLL's or code files that come with the generator. Read the manual.

CodingBarfield
  • 3,392
  • 2
  • 27
  • 54
0

You typically start a SqlTransaction by calling BeginTransaction() on your current connection. Looks like your "Generator" uses some TransactionManager class which it generates or which is delivered with it.

0x434D53
  • 1,425
  • 12
  • 20