string name = ""; 
if (Session["usernames"] != "" & Session["usernames"] != null)
 { name = Session["usernames"].ToString(); SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["soom_dbConnectionString"].ConnectionString);
 SqlCommand command = new SqlCommand("SELECT user_type FROM user_data where user_name='"+name+"'"); command.Connection = connection;
 command.CommandType = CommandType.Text;
 connection.Open(); SqlDataReader reader = command.ExecuteReader(CommandBehavior.CloseConnection);
 if (reader.HasRows) {   reader.Read(); 
  if (reader["user_type"]== "1") 
{ Response.Redirect("../admincp/Default.aspx");   } else 
{ Response.Redirect("../Access_Denied.aspx");   } 
}
 
 
when i use this code and iam sure that the user_type value is 1 it's redirect me to access_denied.aspx idk Why
and when i change the code to
string name = "";
 if (Session["usernames"] != "" & Session["usernames"] != null)
 { name = Session["usernames"].ToString(); SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["soom_dbConnectionString"].ConnectionString);
 SqlCommand command = new SqlCommand("SELECT user_type FROM user_data where user_name='"+name+"'"); command.Connection = connection; 
command.CommandType = CommandType.Text; 
connection.Open(); 
SqlDataReader reader = command.ExecuteReader(CommandBehavior.CloseConnection); 
if (reader.HasRows)
 {   reader.Read(); string type = reader["user_type"].ToString(); if (type == "1") 
{ Response.Redirect("../admincp/Default.aspx"); } else
 { Response.Redirect("../Access_Denied.aspx");  } 
}
 
i enter infinite loop 
waiting for the best answer
thanks in advance