Information générale
Catégorie:
The Mere Mortals .NET Framework
Titre:
Different business objects with the same sql parameters
Versions des environnements
Network:
Windows 2003 Server
In a win form I have three consecutive queries, each from a different business object.
Prior to executing the queries I have gathered some criteria from the UI. Due to this I retrieve data using parameterized queries.
Within each query, which is dynamic, is a base or minimum query that executes in case there are no criteria from the UI.
As an argument to each of the queries I give a string containing all the extra criteria that is going into the query and the IDbDataParameter[] with the SqlParameters.
Since each query is going to use the same criteria i thought that I could just call each query with the same criteria string and IDbDataParameter[]. But when executing the second query I receive the following System.ArgumentException from the SQLServer (I guess?) : "The SqlParameter with ParameterName '@address' is already contained by another SqlParameterCollection."
The error occurs when the parameters of the IDbDataParameter[] is added to the DataCommand.Parameters SqlParameterCollection. What I don't get is why these parameters are still there after I have successfully received a result from the first query, from the first business object. And when is this SqlParameterCollection emptied?
All help is welcomed.
Best regards
Filip
Suivant
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement