Parameter count mismatch error when calling a stored procedure

Posts   
 
    
Posts: 64
Joined: 30-Aug-2010
# Posted on: 28-Mar-2011 11:05:41   

Hello I am trying to execute a stored procedure from my c# application using the AddCallBack metod from UnitOfWork2.

I am using LLBLGen Pro 3, and VisualStudio 2008.

This is done the following way:


UnitOfWork2 unit = new UnitOfWork2();
unit.AddCallBack(new ActionProcedures.CONTRAT_RECALCULMONTANTSPDRCallBack(ActionProcedures.CONTRAT_RECALCULMONTANTSPDR), PreEntityInsert, false, parameters.ToArray());

IDataAccessAdapter adapter = (IDataAccessAdapter)(new MyDataAccessAdapter());
adapter.CommandTimeOut = 300000;
unit.Commit(adapter, true);  

the MyDataAccessAdapter inherits from the DataAccessAdapter.

The commit is executed with errors, and the error message is : "Parameter count mismatch."

I saw that the error is thrown when in the UnitOfWork2, the followind instructions is executed:


switch(blockToProcess)
{
case UnitOfWorkBlockType.Inserts:
#if !CF
                TraceHelper.WriteLineIf(TraceHelper.PersistenceExecutionSwitch.TraceVerbose, "\tHandling Pre Insert CallBacks.");
foreach(UnitOfWorkCallBackElement2 element in _callBacksPreInsert)
{
element.DelegateToCall.DynamicInvoke(ConstructParameters(element.Parameters, adapterToUse, element.PassInAdapter));
}

so, the element.DelegateToCall.DynamicInvoke(ConstructParameters(element.Parameters, adapterToUse, element.PassInAdapter)); throws the exception.

Could you please help

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39908
Joined: 17-Aug-2003
# Posted on: 28-Mar-2011 11:38:33   

which version, build nr? please make sure you're using the latest build of the version you're using (3.0 ? 3.1?)

Frans Bouma | Lead developer LLBLGen Pro
Posts: 64
Joined: 30-Aug-2010
# Posted on: 28-Mar-2011 14:23:05   

Hello The version is 3.0.

I have downloaded the latest build, from 26.01.2011, reversed engieered to entities and regenerated, but I am getting the same error.

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 28-Mar-2011 17:46:58   

Is there a chance the code is not in Sync with the database? i.e. Could it be that you need to refresh the catalog again and re-generate the code. Might be the SP DDL has changed since the last refresh/generation.

Posts: 64
Joined: 30-Aug-2010
# Posted on: 04-Apr-2011 11:38:08   

This following modification seems to solve ths error, allthought I don't understand why it needs a new adapter:

Instead of

UnitOfWork2 unit = new UnitOfWork2();
unit.AddCallBack(new ActionProcedures.CONTRAT_RECALCULMONTANTSPDRCallBack(ActionProcedures.CONTRAT_RECALCULMONTANTSPDR), PreEntityInsert, [b]false[/b], parameters.ToArray());

I have modified in

UnitOfWork2 unit = new UnitOfWork2();
unit.AddCallBack(new ActionProcedures.CONTRAT_RECALCULMONTANTSPDRCallBack(ActionProcedures.CONTRAT_RECALCULMONTANTSPDR), PreEntityInsert, [b]true[/b], parameters.ToArray());

.

But after doing this, I was getting another error message,

Object of type 'System.Decimal' cannot be converted to type 'System.Int64'

. This was I guess, because after applying the type convertor it converted the types for parameters as well? I am asking this because I thought that the type converter doesn't affect the storedprocedures/functions parametres and return types...

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 04-Apr-2011 16:13:12   

This following modification seems to solve ths error, allthought I don't understand why it needs a new adapter:

On the contrary, "true" is for using the current adapter. "false" is for using a new one.