I couldn't really find posts that answered this specific scenario. Plus maybe I am just really tired. Anyway, I am working on a login authentication for WinForms. I have a class named DBFunctions.cs which hold database connection info etc. I am stuck with this "The left-hand side of an assignment must be a variable, property or indexer" error in C#. Please find my current code below. Thanks in advance.
namespace emsdashboard
{
public partial class Login : Form
{
public Login()
{
InitializeComponent();
}
//Contains the SQL string and other information to process
//user login.
public object VerifyUser(string userId, string password)
{
DBFunctions dbInfo = new DBFunctions();
bool status = false;
string verifyUserQry = "SELECT * FROM Employee WHERE UserName = '" + userId + "' AND Password = '" + password + "'";
DataTable dt = default(DataTable);
dt = dbInfo.OpenDTConnection(verifyUserQry);
if (dt.Rows.Count == 1)
{
status = true;
}
return status;
}
//When the login button is clicked. Check to see if the user
//entered a username and/or password. Also verify the username
//and the password are correct, else display an error message.
private void btnLogin_Click(object sender, EventArgs e)
{
if(tbxUsername.Text=="" || tbxPassword.Text=="")
{
MessageBox.Show("Username and Password cannot be blank", "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
else
{
if (VerifyUser(tbxUsername.Text, tbxPassword.Text) = true)
{
this.Hide();
}
}
}
}
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…