Login.aspx

protected void btnLogin_Click(object sender, EventArgs e)
    {
        String tbNRIC = txtLogUsername.Text.ToString();
        String tbPassword = txtLogPassword.Text.ToString();

        PatientDAO fmTd = new PatientDAO();
        fmTd.getPatientByNricPassword(tbNRIC, tbPassword);

        if(?? > 0)
        {
            Response.Redirect("Home.aspx");
        }
        else
        {

        }
    }

How to i response.redirect after checking if username and password match?

PatientDAO.cs

public int getPatientByNricPassword(String tbNRIC, String tbPassword)
        {
            string DBConnect = ConfigurationManager.ConnectionStrings["ConnStr"].ConnectionString;

            SqlDataAdapter da;
            DataSet ds = new DataSet();
            Patient mypatient = new Patient();

            StringBuilder sqlStr = new StringBuilder();

            int result = 0;

            sqlStr.AppendLine("Select * from Login where");
            sqlStr.AppendLine("tbNRIC = @paratbNRIC AND tbPassword = @paratbPassword");

            try
            {
                SqlConnection myConn = new SqlConnection(DBConnect);
                da = new SqlDataAdapter(sqlStr.ToString(), myConn);

                da.SelectCommand.Parameters.AddWithValue("@paratbNRIC", tbNRIC);
                da.SelectCommand.Parameters.AddWithValue("@paratbPassword", tbPassword);
                DataTable dt = new DataTable();
                da.Fill(dt);
            }
            catch (SqlException ex)
            {
                logManager log = new logManager();
                log.addLog("PatientDAO.getPatientByNricPassword", sqlStr.ToString(), ex);
                mypatient = null;
            }
            return result;
        }

How do i pass the result to Login.aspx?

Patient.cs

public class Patient
    {
        public string tbNRIC { get; set; }
        public string tbPassword { get; set; }
    }

How to check from PatientDAO to see if Username and Password Match and Login.aspx Response.Redirect.

Related posts

Recent Viewed