I keep getting this error :
The parameterized query \'(@AdminEmail nvarchar(4000),@AdminPassword nvarchar(4000))SELECT\' expects the parameter \'@A
Is it possible that the EMail property is null (Email is Nothing)? I think you might get that error in that case. Be sure that EMail = String.Empty or EMail = "" before you set your parameter value.
Edit: Or as another answer suggests, you can send DBNull.Value instead if you actually want nulls in your database.
Your @AdminEmail
variable EMail
is null. You cannot pass a null
on a required parameter. Use DBNull.Value
.
When using null
, you are informing Sql Server that you are omitting the parameter. This can be useful for an optional parameter with a default value, but causes an error for a required parameter.
I recommend that you use always use a utility function when passing a value to a command parameter.
For example:
public static object GetDataValue(object value)
{
if(value == null)
{
return DBNull.Value;
}
return value;
}
and then use
cmd.Parameters.AddWithValue("@AdminEmail", GetDataValue(EMail))
Step through your code and see what the value of Email
and Password
are. Chances are they are null.