views:

22

answers:

0

I am a beginner in this area, but the code I write is right out of my textbook (Professional C# 2008, from Wrox). The example in the textbook is about Microsoft SQL Server, so the problem is most likely related to the fact that I work against an Oracle database, using System.Data.OracleClient:

        OracleConnection conn = GetDatabaseConnection("*****ConnectionString")
              :
              :
        MyDataContext dc = new MyDataContext(conn)
              :
              :
        Sample s = new Sample() {  .... initialization ..... }
        using (TransactionScope myScope = new TransactionScope())
        {

            dc.Samples.InsertOnSubmit(s);
            dc.SubmitChanges();
            myScope.Complete();
        }

"Sample" is a hand-coded LINQ-to-SQL mapped class.

The call of SubmitChanges() throws the exception mentioned. The explanation of the ORA error code is not very useful: "An attempt was made to start a transaction, while attached to a non-migrateable transaction".

What am I doing wrong? It could be anything, as I have not yet succeeded in updating my database via ADO.NET.

I should mention, that using a transaction scope is not essential for this application (although I will need it in other contexts), but if I do not set up the transaction, the SubmitChanges simply fails with a different ORA error code, making noise about a missing transaction.

If you cannot say what is wrong I will be grateful for just a code snippet that works for you and does something similar.