2014年7月13日 星期日

[RESOLVED] How to do Update Profle page using , I am facing some problem please help.


Sir after login I come on profile page where information is showing like :


First Name: Sachin


Last Name : Agarwal


but it is not editable you can just see  and information is loading from database so now if you want to edit this information so I create one button Edit on same page when someone will click on edit button so new page will be open and I did coding in its
CS page in void Page_Load(object sender, EventArgs e)


  SqlConnection con = new SqlConnection(@"Data Source=USER-PC\SQLEXPRESS;Initial Catalog=Chitrakala;Integrated Security=True");

        con.Open();

        String id = Session["uname"].ToString();

        string query = ("select* from Artist where User_Name='" + id + "'");

        SqlCommand cmd = new SqlCommand(query, con);

        SqlDataAdapter adpt = new SqlDataAdapter(cmd);

        DataTable dt = new DataTable();

        adpt.Fill(dt);



        tb1.Text = dt.Rows[0]["First_Name"].ToString();

        tb2.Text = dt.Rows[0]["Last_Name"].ToString();

        con.Close();


in above coding Artist is my table name and First_Name" and Last_Name is field name in table so due to this coding when some one will click on edit button so information is loading in text box from database :


First Name: Sachin


Last Name : Agarwal


but now it is editable means if I want to change last name so I use backspace to remove Agarwal and write new name .


 now I created A save button on this page and on Save button I did this coding:


 SqlConnection con = new SqlConnection(@"Data Source=USER-PC\SQLEXPRESS;Initial Catalog=Chitrakala;Integrated Security=True");

        con.Open();

       

       String B = tb2.Text;

       String A = tb1.Text;

       

      string id= Session["uname"].ToString();





      string query = "update Artist set Last_name=('" + B + "') where User_Name='" + id + "'";



        SqlCommand cmd = new SqlCommand(query, con);

        cmd.ExecuteNonQuery();

        con.Close();



        Response.Redirect("Customer profile.aspx");


above query is update means after change it will redirect me to previous page means profile page but problem is Change is not done after click on Save button it is redirecting me on Profile page but no changes in Last name , still Agarwal is showing as Last
name so where is problem


Please help.



If you press ctrl+F5 do you see the updated information?



what ??? I am creating website and I am facing this error that Profile is not update please read full question my friend I need your help.



Hi,


According to your description and your code, first, the redirect did not redirect to Customer profile.aspx page, I suggest you check the path is correct. If the Customer profile.aspx page did not exist in the same level with profile.aspx page, please refer
to the code beow to redirect:


Response.Redirect("../Foloder/Customer profile.aspx");

Second I suggest you checking the updating, we should make sure the data in the DataBase, if the data in DataBase did not been updated, I suggest you making some break points to debug steps by steps. We should make sure the connections is connect right,
then we need check updating in the SQL database.


Third, after we redirect to Customer profile.aspx page, we should make sure we will bind new data to the page.


I searched an artical about update in profile, please refer to the link below:


http://asp-net-example.blogspot.com/2009/02/how-to-update-profile-in-aspnet.html


Hope it's useful for you.


Best Regards,


Michelle Ge


沒有留言:

張貼留言