locked
The underlying provider failed on Commit RRS feed

  • Question

  • User1332640826 posted

    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:

    Connection between server and computer is normal
    I can login to the database with username and password
    I have checked the security settings in database (SQL Server) that permission has been granted .
    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 6:37 AM

Answers

  • User753101303 posted

    Hi,

    You should have an inner exception with what happened... nex.GetBaseException().Message might give a more accurate picture...

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, April 14, 2015 7:52 AM

All replies

  • User753101303 posted

    Hi,

    You should have an inner exception with what happened... nex.GetBaseException().Message might give a more accurate picture...

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, April 14, 2015 7:52 AM
  • User1332640826 posted

    Thanks for the Reply, the innerException is:

    "Value cannot be null.\r\nParameter name: connection"

    Tuesday, April 14, 2015 8:24 AM