I have a database. I'm fetching two values from database in the sqlcommand, but one problem I'm facing is that how to get the adminstatus from the table in the reader()..
my code
protected void signin_Click(object sender, EventArgs e)
{
string connectionString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
using (SqlConnection conn = new SqlConnection(connectionString))
using (SqlCommand comm = new SqlCommand("SELECT password,adminstatus FROM usertable WHERE userid = @username", conn))
{
comm.Parameters.AddWithValue("@username", logintext.Text);
conn.Open();
using (SqlDataReader reader = comm.ExecuteReader())
{
if (reader.Read())
{
string password = reader.GetString(0);
//int st =Convert.ToInt32(reader.GetString(1));
//int st = reader.GetInt32(0);
if (password == logpasstext.Text)
{
Session["userid"] = logintext.Text;
// iframestyle.Attributes["src"] = "userpage.aspx";
iframestyle.Attributes["src"] = "userpage.aspx";
logdiv.Attributes["style"] = "display:none;";
}
/* else if (password == logpasstext.Text && st == 1)
{
Session["userid"] = logintext.Text;
// iframestyle.Attributes["src"] = "userpage.aspx";
iframestyle.Attributes["src"] = "adminpage.aspx";
logdiv.Attributes["style"] = "display:none;";
}*/
else
{
errorsignin.Visible = true;
errorsignin.Text = "INVALID LOGIN";
logdiv.Attributes["style"] = "display:block;";
}
}
else
{
errorsignin.Visible = true;
errorsignin.Text = "INVALID LOGIN";
logdiv.Attributes["style"] = "display:block;";
}
}
}
}
i couldn't get the adminstatus from the table using reader...