Click here to Skip to main content
15,892,059 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello Guys

I am importing 10000 records into the database(MS-SQL) using entity framework.But some time gives me an error randomly:-
An error was reported while committing a database transaction but it could not be determined whether the transaction succeeded or failed on the database server. See the inner exception and http://go.microsoft.com/fwlink/?LinkId=313468 for more information.

What I have tried:

public int saveCarrierTransaction(CarrierTransactionModel model)
{
try
{
var entity = Mapper.Map<CarrierTransactionModel, CarrierTransaction>(model);
if (entity==null)
throw new ArgumentNullException(nameof(CarrierTransactionModel), "CarrierTransactionModel is not map with entity ");

var isExist = _carrierTransactionRepository.Any(x => x.AccountNumber == entity.AccountNumber && x.Balance == entity.Balance && x.CubicValue == entity.CubicValue && x.DateTime == entity.DateTime &&
x.DeclaredValue == entity.DeclaredValue && x.DeliveryDate == entity.DeliveryDate && x.Destination==entity.Destination &&x.DestinationAddress==x.DestinationAddress&&x.DestinationCity==entity.DestinationCity&&
x.DestinationCompanyName==entity.DestinationCompanyName&&x.DestinationCountry==entity.DestinationCountry&&x.DestinationName==entity.DestinationName&&x.DestinationState==entity.DestinationState&&
x.DestinationZip==entity.DestinationZip&&x.DimensionalWeight==entity.DimensionalWeight&&x.Email==entity.Email&&x.GroupCode==entity.GroupCode&&x.Height==entity.Height&&x.IsCubic==entity.IsCubic&&
x.Length==entity.Length&&x.MailClass==entity.MailClass&&x.OptionalServices==entity.OptionalServices&&x.Origin==entity.Origin&& x.PackageDescription==entity.PackageDescription&&x.Phone==entity.Phone&&
x.PostageAmt==entity.PostageAmt&&x.Postmark==entity.Postmark&&x.Reference2==entity.Reference2&&x.Reference3==entity.Reference3&&x.Reference4==entity.Reference4&&x.ReferenceID==entity .ReferenceID&&x.RefundStatus==entity.RefundStatus&&
x.StatusCode==entity.StatusCode&&x.StatusDescription==entity.StatusDescription&&x.Total==entity.Total&&x.TrackingNumber==entity.TrackingNumber&&x.TransactionId==entity.TransactionId&&x.Type==entity.Type&&
x.Weight==entity.Weight&&x.Width==entity.Width&&x.Zone==entity.Zone);

if (isExist)
return 0;
_carrierTransactionRepository.Insert(entity);
System.Console.Error.WriteLine("Insert CarrierTransaction: " + entity.AccountNumber);
// Log.WriteToFile("Insert CarrierTransaction: " + entity.AccountNumber);
return _carrierTransactionRepository.Save();
}
catch (Exception ex)
{
Log.WriteToFile("Error: " + ex.Message);
System.Console.Error.WriteLine("Error: " +ex.Message);
throw ex;
}

}
Posted
Updated 18-Mar-18 0:06am
Comments
CHill60 18-Mar-18 6:01am    
And what did the inner exception say?

1 solution

If you actually go to the page given to you in the exception report they give you three possible solutions

Microsoft suggesstions
[^]

I don't think you'll get any better advice here
 
Share this answer
 

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