Hallo I am still new in this game. I am struggling to select the username and password from the database to verify it.
What this below mentioned code can do is ONLY select the username.
I need help to modify the select statement to select both username and password.
public override int SelectUser(string username, ref User user)
{
int rc = 0;
try
{
_sqlCon = new SQLiteConnection(_conStr);
bool bRead = false;
user = new User();
_sqlCon.Open();
// This selection string is where I am struggling.
string selectQuery = "SELECT * FROM Users WHERE [uUsername] = ' " + username + " ' ";
SQLiteCommand sqlCmd = new SQLiteCommand(selectQuery, _sqlCon);
SQLiteDataReader dataReader = sqlCmd.ExecuteReader();
bRead = dataReader.Read();
if(bRead == true)
{
user.Username = Convert.ToString(dataReader["uUsername"]);
user.Password = Convert.ToString(dataReader["uPW"]);
rc = 0;
}// end if
else
{
rc = -1;
}// end else
dataReader.Close();
}// end try
catch(Exception ex)
{
throw ex;
}// end catch
finally
{
_sqlCon.Close();
}// end finally
return rc;
}// end method