Click here to Skip to main content
15,885,278 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello,

I am having a problem with commit.

Here is the code where program stuck.

C#
 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
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900