Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Passing Command.CommandType To Overloaded Method
Message
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Divers
Thread ID:
01389389
Message ID:
01389436
Vues:
36
Hi,

Just make the Type parameter nullable:
public DataSet ExecuteQuery(string sCommand, string sTableName, SqlParameter[] aParams, CommandType? Type)
Or, better, you could overload ExecuteQuery() to take either three or four parameters....
public DataSet ExecuteQuery(string sCommand, string sTableName, SqlParameter[] aParams)
{
   DataSet.ExecuteQuery(sCommand,sTableName,aParams,CommandType.Text);
}

public DataSet ExecuteQuery(string sCommand, string sTableName, SqlParameter[] aParams, CommandType Type)
{
     oCommand.CommandType = Type;
    // etc
}
>I want to set up the following:
>
>
>public DataSet ExecuteQuery(string sCommand, string sTableName, SqlParameter[] aParams)
>{
>    return ExecuteQuery(sCommand, sTableName, aParams, null);
>}
>public DataSet ExecuteQuery(string sCommand, string sTableName, SqlParameter[] aParams, CommandType Type)
>{
>.
>.
>.
>    if (Type == null)
>    {
>        Type = CommandType.Text;
>    }
>    oCommand.CommandType = Type;
>
>}
>
>
>This doesn't compile because I can't pass null to the last param, and I can't check in the IF to see if the param is null. What's the right way to do this?
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform