SqlConnection sqlcon = new SqlConnection("your connection string");
string wherstring = "UserName='" + usernametexbox.Text + "' and Password='" + passwordtextbox.Text + "'";
string strQuery="SELECT type FROM USERS "+wherstring ;
SqlCommand sqlcmd = new SqlCommand(strQuery, sqlcon);
if (sqlcon.State == ConnectionState.Open)
sqlcon.Close();
sqlcon.Open();
object obj = sqlcmd.ExecuteScalar();
sqlcon.Close();
if(obj!=null)
{
string type=convert.toint32(obj);
if(type=="admin")
{
Response.Redirect("adminpage.aspx", false);
}
else if(type=="student")
{
Response.Redirect("studentpage.aspx", false);
}
else if(type=="teacher")
{
Response.Redirect("teacherpage.aspx", false);
}
}
else
{
}