Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Problem converting SqlDbType.Int to int?
Message
 
 
À
Tous
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Titre:
Problem converting SqlDbType.Int to int?
Versions des environnements
OS:
Windows XP
Database:
Visual FoxPro
Divers
Thread ID:
01330083
Message ID:
01330083
Vues:
73
Hi everybody,

I have the following function:
public static int? FindPersonID(string Name, DateTime DOB, int? SiteID)
    {
        int? result;
        SqlParameter[] parameters = new SqlParameter[4];
        parameters[0] = new SqlParameter("PersonID", SqlDbType.Int);
        parameters[0].Direction = ParameterDirection.Output;

        parameters[1] = new SqlParameter("FullName", SqlDbType.VarChar, 65);
        parameters[1].Value = Name.Trim(); 
        parameters[2] = new SqlParameter("SiteID", SqlDbType.Int);
        parameters[2].IsNullable = true; 
        parameters[2].Value = SiteID;
        parameters[3] = new SqlParameter("DOB", SqlDbType.DateTime);
        parameters[3].Value = DOB; 
                        
        Util.RunStoredProc("FindPersonByName", parameters);
        result = parameters[0];
        return result;
    }
It gives me an error on the result = parameters[0]; line
Error 66 Cannot implicitly convert type 'System.Data.SqlClient.SqlParameter' to 'int?'

I'm not sure what should I do to fix it. In my stored procedure I return NULL by default if the person is not found.

I have another related question.
I want to have an overload without a DOB (this parameter is optional).

I'm not sure this syntax
   public static int? FindPersonID(string Name, int? SiteID)
    { return FindPersonID(Name, null, SiteID); }
is correct for the datetime second parameter.

Thanks a lot in advance.
If it's not broken, fix it until it is.


My Blog
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform