Rocky Rocky

Rocky Rocky

  • NA
  • 317
  • 152.3k

What Was Error in My code Of C# page?

Jun 28 2013 1:01 AM

for above the requirement i made the code like these its also working well .



protected void Page_Load(object sender, EventArgs e)
{

string us = Session["username"].ToString();

if(us!=null)
{
Label1.Text= us.ToString();
Label1.ForeColor = System.Drawing.Color.BlueViolet;
Label1.Font.Bold = true;
}


//string uname = Session["username"].ToString();
SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["AccessConnectionString"].ConnectionString);
SqlCommand cmd = new SqlCommand("ju", conn);
cmd.Parameters.AddWithValue("@username", us);
//cmd.Parameters.AddWithValue("@pwd", SqlDbType.VarChar(20).Value);
cmd.CommandType = CommandType.StoredProcedure;
conn.Open();
SqlDataReader dr = cmd.ExecuteReader();

while (dr.Read())
{
TxtFNme.Text = dr["fst_name"].ToString();
TxtLNme.Text = dr["lst_name"].ToString();
Txtage.Text = dr["AGE"].ToString();
TxtGen.Text = dr["Gender"].ToString();
TxtDesig.Text = dr["designation"].ToString();
TxtRepto.Text = dr["Reporting_to"].ToString();
TxtLctn.Text = dr["location"].ToString();
DropDownList1.Text = dr["costcenter_id"].ToString();
DropDownList2.Text = dr["proof_type_id"].ToString();
}
dr.Close();
// Label1.Text = Session["username"].ToString();
conn.Close();
}


friends i ve different username like eexample
1)ram
2)david
3)kumar

above the code always display ram details oly... when i try logged on sum other users also deafult showing ram details only.
do The need full.

Answers (2)