Error "Must declare the scalar variable"

Error "Must declare the scalar variable"


In recent development, I have been presented with a new error in advanced queries.

I create an advanced query, verify it with no errors and test it with success. When I run the application I get the error:

"Error in advanced query GetVaiturasComRM in ActualizarTabela in RegistoManutencaoPorViaturasList in Manutencao in TCM (SELECT {MANUTENCAO_REGISTO}.[ViaturaId], {VIATURA}.[Designacao], {VIATURA}.[RodagemTacografo] FROM {MANUTENCAO_REGISTO} Join {VIATURA} On {MANUTENCAO_REGISTO}.[ViaturaId] ={VIATURA}.[Id] WHERE {MANUTENCAO_REGISTO}.[ViaturaId] = @Viat or isnull(@Viat,'')='' GROUP By {MANUTENCAO_REGISTO}.[ViaturaId], {VIATURA}.[Designacao], {VIATURA}.[RodagemTacografo] ): Must declare the scalar variable "@qpViat".

There is no varible missing, as I run the query in test mode and it works just fine. I wonder if any one knows how to solve this problem.