Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
DbParameter vs SqlParameter Problem
Message
Information générale
Forum:
ASP.NET
Catégorie:
ADO.NET
Divers
Thread ID:
01447664
Message ID:
01447674
Vues:
43
>I have a data access class with an ExecuteQuery method. It takes the following parameters:
>
>
>public DataSet ExecuteQuery(string Command, List<DbParameter> Parameters, CommandType Type)
>{
>.
>.
>.
>}
>
>
>I'm trying to use it like this:
>
>
>public static bool DeleteCategory(int CategoryKey)
>{
>    SqlParameter pRecordKey = new SqlParameter("@CategoryKey", CategoryKey);
>
>    List<SqlParameter> colParams = new List<SqlParameter>();
>    colParams.Add(pRecordKey);
>
>    try
>    {
>        DataSet ds = DataProcs.ExecuteQuery("as_RemoveCategory", colParams, CommandType.StoredProcedure);
>    }
>    catch (Exception e)
>    {
>        throw;
>    }
>}
>
>
>
>It won't compile. Getting:
>
>The best overloaded method match for 'Marois.Common.DataAccess.DataAccess.ExecuteQuery(string, string,
>System.Collections.Generic.List<System.Data.Common.DbParameter>)' has some invalid arguments
>
>
>I thought that since the class is using DbParameters that I could pass SqlParamaters since SqlParameter inherits from System.Data.Common.DbParameter.
>
>Anyone know what't wrong?

Try casting colParams to DBParameter collection
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform