string outPutValues = prm[1].Value.ToString();
this line is giving the error
Well...I'm not surprised...
prm = new SqlParameter[] {
new SqlParameter ("@UserName" , SqlDbType .VarChar),
new SqlParameter ("@msg" , SqlDbType .VarChar ,100)
};
prm[0].Value = modelManageUserRole.userName;
prm[1].Direction = ParameterDirection.Output;
status = context.GetReaderWithPrm("usp_GetUserRole", prm);
string outPutValues = prm[1].Value.ToString();
You don't assign any value to the Value property of prm[1], so when you try to call ToString, it's working from a
null
value, and you get the exception.
If your context.GetReaderWithPrm method is calling a stored procedure which returns a value via the parameter, then you need to set it as an Output parameter in order to get values back.
Otherwise, check your method and see what it does with the parameters and if it modifies them in any way.