I'm using SQLHELPER classes for getting the id from the procedure. I had written the following code :
string constr = ConfigurationManager.ConnectionStrings["constr"].ConnectionString;
public int CheckUser(string userName,string password)
{
SqlParameter[] spc = new SqlParameter[5];
spc = SqlHelperParameterCache.GetSpParameterSet(constr, "CheckUser");
spc[0].Value = userName;
spc[1].Value =password;
spc[2] = new SqlParameter("@userExist", SqlDbType.Int, 32);
spc[2].Direction = ParameterDirection.Output;
int res = (int)SqlHelper.ExecuteScalar(constr, CommandType.StoredProcedure, "CheckUser", spc);
return res;
}
I'm pssing the username and password but I'm facing "Null reference exception was unhandled by the user" run time exception. When I debug I got the both values which I sent exactly.
Create proc CheckUser
@userName varchar(50),
@password varchar(50),
@userExist int output
as
begin
set @userExist= (select COUNT(*)
from tbluserInfo
where UserName=@userName and [Password]=@password)
select [uid] from tbluserInfo
where UserName=@userName and [Password]=@password
end