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
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)
Additional error information:
Parameter is not valid.
Exception type: BAMRuntimeException
Target Site: Void GetSqlScriptForActivity(System.IO.TextWriter, System.Data.SqlClient.SqlConnection, System.Data.SqlClient.SqlTransaction)
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)
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).
es.UpdateActivity("myActivity", activityID, "myCheckPoint", myCheckPointValue)
solved the problem.