none
The underlying provider failed on Commit. RRS feed

  • Question

  • Hello,

    I am having a problem with commit.

    Here is the code where program stuck.

     using (var transaction = DataEngine.Context.Database.BeginTransaction(IsolationLevel.ReadCommitted))
                {
                    try
                    {
     var createResult = DataEngine.Context.Customer_Modify(BusinessID, cutomerName,usermodified);
    
                        Logger.LogTrace(createResult.ToString());
    await DataEngine.Context.SaveChangesAsync();
    transaction.Commit();
                        
                    }
                    catch (Exception ex)
                    {
                        Logger.LogTrace(ex.Message);
    
                        // Attempt a rollback
                        try
                        {
                            transaction.Rollback();
                        }
                        catch (Exception nex)
                        {
                            Logger.LogTrace(nex.Message);
                            throw;
                        }
    
                        throw;
                    }
                }

    After running the above code, I check the variable query and found an exception

    The underlying provider failed on Open.

    I've checked:

    1. Connection between server and computer is normal
    2. I can login to the database with username and password 
    3. I have checked the security settings in database (SQL Server) that permission has been granted .
    4. I can able to 'Insert' records but not 'Update'

    Why does this exception happen? I'm using .net 4.5

    Thanks


    Tuesday, April 14, 2015 10:10 AM

All replies

  • Hi SamKri,

    You could try to enabling "Allow Remote Clients" in DTC config.

    You could open the DTC config by running dcomcnfg, Component Services -> Computers -> My Computer -> Distributed Transaction Coordinator -> Right click to  Local DTC -> Security.

    If this is still not working, the issue may be caused by the connectionString, you could share the connectionString with us, we could help you better.

    Regards,

    Youjun Tang


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Wednesday, April 15, 2015 3:12 AM
  • You need to see if there is a message in the InnerException message property as to what is the problem that caused the exception by using Exception.ToString() to expose the InnerException message if any.
    Friday, April 17, 2015 6:53 PM
  • >You could try to enabling "Allow Remote Clients" in DTC config.

    No.  That's irrelevant.  DTC is not involved in clients connecting to SQL Server.

    David


    David http://blogs.msdn.com/b/dbrowne/


    Friday, April 17, 2015 7:16 PM