How do I login based on user role? This is my C# code but its not working
Server side Code:
protected void Button1_Click(object sender, EventArgs e)
{
if (txtUsername.Text != "" & txtPassword.Text != "")
{
string check = "select count(*) from [Users] where email = '" + txtUsername.Text + "' and pass = '" + txtPassword.Text + "'";
SqlCommand com = new SqlCommand(check, con);
con.Open();
int temp = Convert.ToInt32(com.ExecuteScalar().ToString());
con.Close();
if (temp == 1)
{
string user = txtUsername.Text.Trim();
com.CommandText = "select * from Users where email='" + txtUsername.Text + "'";
com.Connection = con;
sda.SelectCommand = com;
sda.Fill(ds, "detail");
if (ds.Tables[0].Rows.Count > 0)
{
string UserRole;
UserRole = dt.Rows[0][4].ToString().Trim();
if (UserRole == "U")
{
Session["user"] = user;
txtUsername.Text = "";
txtPassword.Text = "";
Response.Redirect("UsersHome.aspx");
}
if (UserRole == "A")
{
Session["user"] = user;
txtUsername.Text = "";
txtPassword.Text = "";
Response.Redirect("Home.aspx");
}
}
}