Database Error When Calling Basket.Save()

This is a discussion on Database Error When Calling Basket.Save() within the Commerce server forums in Microsoft Tools category; About 8 - 10 times per day we are receiving an error when calling the Basket.Save() method. Anyone know what could be causing this? Thank you! Glen Fergo Exception Details: System.Data.SqlClient.SqlException: Cannot insert duplicate key row in object 'dbo.OrderTemplatesAndBaskets' with unique index 'OrderTemplatesAndBaskets_UniqueConstraints'. StackTrace: Server stack trace: at System.Data.SqlClient.SqlConnection.OnError(SqlExc eption exception, Boolean breakConnection) at System.Data.SqlClient.SqlInternalConnection.OnErro r(SqlException exception, Boolean breakConnection) at System.Data.SqlClient.TdsParser.ThrowExceptionAndW arning(TdsParserStateObject stateObj) at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) at System.Data.SqlClient.SqlDataReader.HasMoreRows() at System.Data.SqlClient.SqlDataReader.ReadInternal(B oolean setTimeout) at System.Data.SqlClient.SqlDataReader.NextResult() at System.Data.ProviderBase.DataReaderContainer.NextR esult() at System.Data.Common.DataAdapter.FillNextResult(Data ReaderContainer dataReader) at System.Data.Common.DataAdapter.FillFromReader(Data Set dataset, DataTable datatable, String srcTable, DataReaderContainer dataReader, Int32 ...

Go Back   Application Development Forum > Microsoft Tools > Commerce server

Object Mix

Register FAQ Calendar Search Today's Posts Mark Forums Read
  #1  
Old 03-07-2008, 08:37 AM
gfergo@gmail.com
Guest
 
Default Database Error When Calling Basket.Save()

About 8 - 10 times per day we are receiving an error when calling the
Basket.Save() method.

Anyone know what could be causing this?

Thank you!

Glen Fergo


Exception Details: System.Data.SqlClient.SqlException: Cannot insert
duplicate key row in object 'dbo.OrderTemplatesAndBaskets' with unique
index 'OrderTemplatesAndBaskets_UniqueConstraints'.

StackTrace: Server stack trace: at
System.Data.SqlClient.SqlConnection.OnError(SqlExc eption exception,
Boolean breakConnection) at
System.Data.SqlClient.SqlInternalConnection.OnErro r(SqlException
exception, Boolean breakConnection) at
System.Data.SqlClient.TdsParser.ThrowExceptionAndW arning(TdsParserStateObject
stateObj) at System.Data.SqlClient.TdsParser.Run(RunBehavior
runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream,
BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject
stateObj) at System.Data.SqlClient.SqlDataReader.HasMoreRows() at
System.Data.SqlClient.SqlDataReader.ReadInternal(B oolean setTimeout)
at System.Data.SqlClient.SqlDataReader.NextResult() at
System.Data.ProviderBase.DataReaderContainer.NextR esult() at
System.Data.Common.DataAdapter.FillNextResult(Data ReaderContainer
dataReader) at System.Data.Common.DataAdapter.FillFromReader(Data Set
dataset, DataTable datatable, String srcTable, DataReaderContainer
dataReader, Int32 startRecord, Int32 maxRecords, DataColumn
parentChapterColumn, Object parentChapterValue) at
System.Data.Common.DataAdapter.Fill(DataSet dataSet, String srcTable,
IDataReader dataReader, Int32 startRecord, Int32 maxRecords) at
System.Data.Common.DbDataAdapter.FillInternal(Data Set dataset,
DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String
srcTable, IDbCommand command, CommandBehavior behavior) at
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32
startRecord, Int32 maxRecords, String srcTable, IDbCommand command,
CommandBehavior behavior) at
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet) at
Microsoft.CommerceServer.Internal.Orders.MtsHelper .ExecuteSqlCommandDataSet(String
connStr, String commandText, CommandType commandType, ArrayList
sqlParameterHelpers, Int32 timeout) at
System.Runtime.Remoting.Messaging.Message.Dispatch (Object target,
Boolean fExecuteInContext) at
System.Runtime.Remoting.Messaging.StackBuilderSink .SyncProcessMessage(IMessage
msg, Int32 methodPtr, Boolean fExecuteInContext) Exception rethrown at
[0]: at
System.Runtime.Remoting.Proxies.RealProxy.HandleRe turnMessage(IMessage
reqMsg, IMessage retMsg) at
System.Runtime.Remoting.Proxies.RealProxy.PrivateI nvoke(MessageData&
msgData, Int32 type) at
Microsoft.CommerceServer.Internal.Orders.MtsHelper .ExecuteSqlCommandDataSet(String
connStr, String commandText, CommandType commandType, ArrayList
sqlParameterHelpers, Int32 timeout) at
Microsoft.CommerceServer.Runtime.Orders.OrderGroup .Save(Int32
maxInstances, String baseClassName, String tableInsertSprocName,
PropertyColumnMapping[] stronglyTypedMappings, PropertyColumnMapping[]
weaklyTypedMappings, DetailedSqlColumnInformation indexerColumnInfo)
at Microsoft.CommerceServer.Runtime.Orders.Basket.Sav e() at
CsBaseOrder.GetOrderForm(String key)
Reply With Quote
  #2  
Old 03-09-2008, 03:39 PM
Lasse
Guest
 
Default RE: Database Error When Calling Basket.Save()

Hi Glen,

We've seen that error on one of our sites before - I seem to remeber it has
to do with people hitting a post button (or a link) several times and thus
executing several (probably just two) threads that try and persist the same
newly created basket. Whichever thread comes last receives the index error,
and unfortunately this will be the one the end-user sees :-(

- Lasse

"gfergo@gmail.com" wrote:

> About 8 - 10 times per day we are receiving an error when calling the
> Basket.Save() method.
>
> Anyone know what could be causing this?
>
> Thank you!
>
> Glen Fergo
>
>
> Exception Details: System.Data.SqlClient.SqlException: Cannot insert
> duplicate key row in object 'dbo.OrderTemplatesAndBaskets' with unique
> index 'OrderTemplatesAndBaskets_UniqueConstraints'.
>
> StackTrace: Server stack trace: at
> System.Data.SqlClient.SqlConnection.OnError(SqlExc eption exception,
> Boolean breakConnection) at
> System.Data.SqlClient.SqlInternalConnection.OnErro r(SqlException
> exception, Boolean breakConnection) at
> System.Data.SqlClient.TdsParser.ThrowExceptionAndW arning(TdsParserStateObject
> stateObj) at System.Data.SqlClient.TdsParser.Run(RunBehavior
> runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream,
> BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject
> stateObj) at System.Data.SqlClient.SqlDataReader.HasMoreRows() at
> System.Data.SqlClient.SqlDataReader.ReadInternal(B oolean setTimeout)
> at System.Data.SqlClient.SqlDataReader.NextResult() at
> System.Data.ProviderBase.DataReaderContainer.NextR esult() at
> System.Data.Common.DataAdapter.FillNextResult(Data ReaderContainer
> dataReader) at System.Data.Common.DataAdapter.FillFromReader(Data Set
> dataset, DataTable datatable, String srcTable, DataReaderContainer
> dataReader, Int32 startRecord, Int32 maxRecords, DataColumn
> parentChapterColumn, Object parentChapterValue) at
> System.Data.Common.DataAdapter.Fill(DataSet dataSet, String srcTable,
> IDataReader dataReader, Int32 startRecord, Int32 maxRecords) at
> System.Data.Common.DbDataAdapter.FillInternal(Data Set dataset,
> DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String
> srcTable, IDbCommand command, CommandBehavior behavior) at
> System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32
> startRecord, Int32 maxRecords, String srcTable, IDbCommand command,
> CommandBehavior behavior) at
> System.Data.Common.DbDataAdapter.Fill(DataSet dataSet) at
> Microsoft.CommerceServer.Internal.Orders.MtsHelper .ExecuteSqlCommandDataSet(String
> connStr, String commandText, CommandType commandType, ArrayList
> sqlParameterHelpers, Int32 timeout) at
> System.Runtime.Remoting.Messaging.Message.Dispatch (Object target,
> Boolean fExecuteInContext) at
> System.Runtime.Remoting.Messaging.StackBuilderSink .SyncProcessMessage(IMessage
> msg, Int32 methodPtr, Boolean fExecuteInContext) Exception rethrown at
> [0]: at
> System.Runtime.Remoting.Proxies.RealProxy.HandleRe turnMessage(IMessage
> reqMsg, IMessage retMsg) at
> System.Runtime.Remoting.Proxies.RealProxy.PrivateI nvoke(MessageData&
> msgData, Int32 type) at
> Microsoft.CommerceServer.Internal.Orders.MtsHelper .ExecuteSqlCommandDataSet(String
> connStr, String commandText, CommandType commandType, ArrayList
> sqlParameterHelpers, Int32 timeout) at
> Microsoft.CommerceServer.Runtime.Orders.OrderGroup .Save(Int32
> maxInstances, String baseClassName, String tableInsertSprocName,
> PropertyColumnMapping[] stronglyTypedMappings, PropertyColumnMapping[]
> weaklyTypedMappings, DetailedSqlColumnInformation indexerColumnInfo)
> at Microsoft.CommerceServer.Runtime.Orders.Basket.Sav e() at
> CsBaseOrder.GetOrderForm(String key)
>

Reply With Quote
  #3  
Old 03-13-2008, 11:14 AM
shuchita
Guest
 
Default Re: Database Error When Calling Basket.Save()

On Mar 9, 3:39*pm, Lasse <La...@discussions.microsoft.com> wrote:
> Hi Glen,
>
> We've seen that error on one of our sites before - I seem to remeber it has
> to do with people hitting a post button (or a link) several times and thus
> executing several (probably just two) threads that try and persist the same
> newly created basket. Whichever thread comes last receives the index error,
> and unfortunately this will be the one the end-user sees :-(
>
> - Lasse
>
>
>
> "gfe...@gmail.com" wrote:
> > About 8 - 10 times per day we are receiving an error when calling the
> > Basket.Save() method.

>
> > Anyone know what could be causing this?

>
> > Thank you!

>
> > Glen Fergo

>
> > Exception Details: System.Data.SqlClient.SqlException:Cannotinsert
> >duplicatekeyrow inobject'dbo.OrderTemplatesAndBaskets' with unique
> > index 'OrderTemplatesAndBaskets_UniqueConstraints'.

>
> > StackTrace: Server stack trace: at
> > System.Data.SqlClient.SqlConnection.OnError(SqlExc eption exception,
> > Boolean breakConnection) at
> > System.Data.SqlClient.SqlInternalConnection.OnErro r(SqlException
> > exception, Boolean breakConnection) at
> >System.Data.SqlClient.TdsParser.ThrowExceptionAnd Warning(TdsParserStateObje*ct
> >stateObj) at System.Data.SqlClient.TdsParser.Run(RunBehavior
> > runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream,
> > BulkCopySimpleResultSet bulkCopyHandler,TdsParserStateObject
> >stateObj) at System.Data.SqlClient.SqlDataReader.HasMoreRows() at
> > System.Data.SqlClient.SqlDataReader.ReadInternal(B oolean setTimeout)
> > at System.Data.SqlClient.SqlDataReader.NextResult() at
> > System.Data.ProviderBase.DataReaderContainer.NextR esult() at
> > System.Data.Common.DataAdapter.FillNextResult(Data ReaderContainer
> > dataReader) at System.Data.Common.DataAdapter.FillFromReader(Data Set
> > dataset, DataTable datatable, String srcTable, DataReaderContainer
> > dataReader, Int32 startRecord, Int32 maxRecords, DataColumn
> > parentChapterColumn,ObjectparentChapterValue) at
> > System.Data.Common.DataAdapter.Fill(DataSet dataSet, String srcTable,
> > IDataReader dataReader, Int32 startRecord, Int32 maxRecords) at
> > System.Data.Common.DbDataAdapter.FillInternal(Data Set dataset,
> > DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String
> > srcTable, IDbCommand command, CommandBehavior behavior) at
> > System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32
> > startRecord, Int32 maxRecords, String srcTable, IDbCommand command,
> > CommandBehavior behavior) at
> > System.Data.Common.DbDataAdapter.Fill(DataSet dataSet) at
> > Microsoft.CommerceServer.Internal.Orders.MtsHelper .ExecuteSqlCommandDataSet*(String
> > connStr, String commandText, CommandType commandType, ArrayList
> > sqlParameterHelpers, Int32 timeout) at
> > System.Runtime.Remoting.Messaging.Message.Dispatch (Objecttarget,
> > Boolean fExecuteInContext) at
> > System.Runtime.Remoting.Messaging.StackBuilderSink .SyncProcessMessage(IMess*age
> > msg, Int32 methodPtr, Boolean fExecuteInContext) Exception rethrown at
> > [0]: at
> > System.Runtime.Remoting.Proxies.RealProxy.HandleRe turnMessage(IMessage
> > reqMsg, IMessage retMsg) at
> > System.Runtime.Remoting.Proxies.RealProxy.PrivateI nvoke(MessageData&
> > msgData, Int32 type) at
> > Microsoft.CommerceServer.Internal.Orders.MtsHelper .ExecuteSqlCommandDataSet*(String
> > connStr, String commandText, CommandType commandType, ArrayList
> > sqlParameterHelpers, Int32 timeout) at
> > Microsoft.CommerceServer.Runtime.Orders.OrderGroup .Save(Int32
> > maxInstances, String baseClassName, String tableInsertSprocName,
> > PropertyColumnMapping[] stronglyTypedMappings, PropertyColumnMapping[]
> > weaklyTypedMappings, DetailedSqlColumnInformation indexerColumnInfo)
> > at Microsoft.CommerceServer.Runtime.Orders.Basket.Sav e() at
> > CsBaseOrder.GetOrderForm(Stringkey)- Hide quoted text -

>
> - Show quoted text -


I also had this in our web site. I can tell you what was my site
problem and how i solved it.
I was getting same error from one of my SQL Server Table Valued
function.
So the problem was in my input parameters which was creating the
return table, which had a primary key and in input i was not sending
list with unique values. So my function was not checking whether the
list is unique or not and it was inserting values in the new table to
return. It was creating the exception.

My suggestion is check what is that function doing and what is it
inserting in this return table which had unique constraint.
Reply With Quote
Reply


Thread Tools
Display Modes


All times are GMT -5. The time now is 06:30 AM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
vB Ad Management by =RedTyger=

In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.