While using BAM API (with BizTalk Server 2006, but I think it would be the same with BizTalk Server 2004), we received an exception like this:

 

 

Failed to execute event.

       

Exception type: BAMTraceException

Source: Microsoft.BizTalk.Bam.EventObservation

Target Site: Boolean PersistNoBatches(System.Data.SqlClient.SqlConnection, Int32)

The following is a stack trace that identifies the location where the exception occured

   at Microsoft.BizTalk.Bam.EventObservation.DirectEventStream.PersistNoBatches(SqlConnection connection, Int32 timeoutValue)

   at Microsoft.BizTalk.Bam.EventObservation.DirectEventStream.Flush()

   at (...)

Additional error information:

        Parameter is not valid.

       

Exception type: BAMRuntimeException

Source: Microsoft.BizTalk.Bam.EventObservation

Target Site: Void GetSqlScriptForActivity(System.IO.TextWriter, System.Data.SqlClient.SqlConnection, System.Data.SqlClient.SqlTransaction)

The following is a stack trace that identifies the location where the exception occured

   at Microsoft.BizTalk.Bam.EventObservation.BAMTraceFragment.GetSqlScriptForActivity(TextWriter scriptWriter, SqlConnection connection, SqlTransaction transaction)

   at Microsoft.BizTalk.Bam.EventObservation.BAMTraceFragment.PersistQueryable(SqlConnection connection, SqlTransaction transaction, Int32 timeoutValue)

   at Microsoft.BizTalk.Bam.EventObservation.DirectEventStream.PersistNoBatches(SqlConnection connection, Int32 timeoutValue)

 

 

 

This came from the fact that we called UpdateActivity with a checkpoint name having a invalid case.

 

Ex: we called

          es.UpdateActivity("myActivity", activityID, "myCheckpoint", myCheckPointValue)

while the name of the checkpoint was myCheckPoint (with an upper case P), not myCheckpoint (lower case p).

Changing to

          es.UpdateActivity("myActivity", activityID, "myCheckPoint", myCheckPointValue)

solved the problem.