Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Problem converting SqlDbType.Int to int?
Message
 
 
To
All
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Title:
Problem converting SqlDbType.Int to int?
Environment versions
OS:
Windows XP
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01330083
Message ID:
01330083
Views:
76
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
Next
Reply
Map
View

Click here to load this message in the networking platform