none
SQL CE 4.0 and TransactionScope RRS feed

  • Question

  • Hi,

    In my application I have 2 methods. First to insert product info to database and second to write prices.

    I use

    public void WriteProductInfo() { using (TransactionScope scope = new TransactionScope()) { using (SqlCeConnection connection = new SqlCeConnection(connectionString)) { connection.Open(); using (SqlCeCommand command = new SqlCeCommand("", connection)) { command.CommandText = "someCOmmand"; this.WritePrices(); } } scope.Complete(); }

    }

    public void WritePrices()
    {
    	    using (SqlCeConnection connection = new SqlCeConnection(connectionString))
                using (SqlCeCommand command = new SqlCeCommand("someCommand", connection))
                {
                        command.ExecuteNonQuery();
                    }
                }
    }

    The error is: "The connection object can not be enlisted in transaction scope".

    There are command parameters and different strings but nothing important so I didnt write them here.

    Thanks

    Friday, June 29, 2012 10:05 PM

Answers

  • Hi, 

    Which line of the code is giving exception? Can you provide stack trace?

    One limitation with TransactinScope and SqlCeConnection, only one connection object can be enlisted.(read from here)


    If this post answers your question, please click "Mark As Answer". If this post is helpful please click "Mark as Helpful".

    • Marked as answer by VyrinSk Monday, July 2, 2012 4:16 PM
    Sunday, July 1, 2012 3:19 PM