Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Different business objects with the same sql parameters
Message
De
19/07/2005 09:24:12
Filip Bruman
Kirschberg Holding
Copenhagen, Denmark
 
 
À
Tous
Information générale
Forum:
ASP.NET
Catégorie:
The Mere Mortals .NET Framework
Titre:
Different business objects with the same sql parameters
Versions des environnements
Environment:
C# 1.1
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
MS SQL Server
Divers
Thread ID:
01033812
Message ID:
01033812
Vues:
67
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
Fil
Voir

Click here to load this message in the networking platform