Must declare the scalar variable
OleDb does not support named parameters. I presume this is what is causing the errors. Instead, within the SQL query, use ?
instead of the param name, and ensure the order of parameters added matches the order they appear in the query.
so:
using(OleDbCommand cmd = new OleDbCommand("SELECT UserID FROM tblUser WHERE Username=? AND Password = ?", conn))
{
cmd.Parameters.AddWithValue("@user", user);
cmd.Parameters.AddWithValue("@pass", pass);
int UserID = (int)cmd.ExecuteScalar();
return UserID < 0 ? -1 : UserID;
}