Click here to Skip to main content
15,885,141 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
private void Bindload()
    {
        lbl_cat.Visible = false;
        if (Session["user"] != null)
        {
            string constr = ConfigurationManager.ConnectionStrings["name"].ConnectionString;
            using (SqlConnection con = new SqlConnection(constr))
            {
                using (SqlCommand cmd = new SqlCommand("SELECT  id_house_manager,name_house_manager,username_house_manager,name_house_manager from tbl where username_house_manager  ='" + Session["user"] + "'", con))
                {
                    con.Open();
                    SqlDataReader reader = cmd.ExecuteReader();
                    while (reader.Read())
                    {
                        lbl_cat.Text = reader["id_house_manager"].ToString();
                        lbl_id.Text = reader["name_house_manager"].ToString();
                        txt_name.Text = reader["name_house_manager"].ToString();
                        Session["id"] = lbl_cat.Text;
                    }
                }
            }
        }
        else
        {
            Session.RemoveAll();
            Response.Redirect("/Default.aspx");
        }
        if (!IsPostBack)
        {
        }
    }    







protected void btn_update_Click(object sender, EventArgs e)
    {


        string cs = ConfigurationManager.ConnectionStrings["name"].ToString();
        using (SqlConnection con = new SqlConnection(cs))
        {
            con.Open();
            using (SqlCommand cmd = new SqlCommand("UPDATE [db].[dbu].[tbl_house_manager] SET [name_house_manager] = @name_house_manager WHERE [username_house_manager] ='" + Session["user"] + "'", con))
            {
                cmd.Parameters.AddWithValue("@name_house_manager", txt_name.Text);

                cmd.ExecuteNonQuery();
                lbl_alert.Text = "thanks";  //after Sucessfully uploaded image
                con.Close();


            }
        }
    }


[edit]Code block added - OriginalGriff[/edit]


What I have tried:

i dont update value in textbox - No error
Posted
Updated 5-Aug-17 5:39am
v2

1 solution

We can't help you with this: it requires the contents of your Session, and your database - neither of which we have access to.

So, its going to be up to you.
Put a breakpoint on the first line in the function, and run your code through the debugger. Then look at your code, and at your data and work out what should happen manually. Then single step each line checking that what you expected to happen is exactly what did. When it isn't, that's when you have a problem, and you can back-track (or run it again and look more closely) to find out why.

Chances are that the SQL SELECT is not returning any rows - but without looking at it running in the debugger, you can't tell.

Sorry, but we can't do that for you - time for you to learn a new (and very, very useful) skill: debugging!
 
Share this answer
 
Comments
Ali Nemati 5-Aug-17 11:45am    
thanks,select command responds but not update
OriginalGriff 5-Aug-17 12:03pm    
So use the debugger and see what exactly is happening. Don't forget to check your page Load event handler and make sure it doesn't play with your Session.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900