Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7634743
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T07:15:29+00:00 2026-05-31T07:15:29+00:00

I am developing a project in ASP.NET with c# and SQL Server 2005 as

  • 0

I am developing a project in ASP.NET with c# and SQL Server 2005 as back end. It includes a page profile.aspx which displays the information of a user from database. The session variable is used to keep track of the current logged in user.

The profiles table in the database contains a username column and 10 others columns like dept, address, contact, skills, interests etc etc.

I am displaying all these values on profile.aspx. Another page is edit_profile.aspx which comes up when the edit button on profile.aspx is clicked. Here the data is displayed in textboxes, with older entries already displayed, which can be edited, and click the Update button to confirm.

The update query runs fine, there is no error, but the values are not updates in the database tables. What is the possible reason? Solution?

Thank you


protected void Page_Load(object sender, EventArgs e)
{
    string CNS = ConfigurationManager.ConnectionStrings["myconn"].ToString();
    SqlConnection con = new SqlConnection(@CNS);
    SqlDataAdapter sda = new SqlDataAdapter("select * from profiles where username='" +     Session["currentusername"].ToString()+"'", con);
    DataSet ds = new DataSet();
    sda.Fill(ds, "profiles");
    txt_name.Text = ds.Tables["profiles"].Rows[0][0].ToString();
    txt_deptt.Text = ds.Tables["profiles"].Rows[0][1].ToString();
    txt_qualificatns.Text = ds.Tables["profiles"].Rows[0][2].ToString();
    txt_add.Text = ds.Tables["profiles"].Rows[0][3].ToString();
    txt_contacts.Text = ds.Tables["profiles"].Rows[0][4].ToString();
    txt_interests.Text = ds.Tables["profiles"].Rows[0][5].ToString();
    txt_awards.Text = ds.Tables["profiles"].Rows[0][6].ToString();
    txt_website.Text = ds.Tables["profiles"].Rows[0][7].ToString();
    txt_skills.Text = ds.Tables["profiles"].Rows[0][8].ToString();
    txt_mstatus.Text = ds.Tables["profiles"].Rows[0][9].ToString();
    ds.Reset();
}



protected void Button1_Click(object sender, EventArgs e)
{
    string CNS = ConfigurationManager.ConnectionStrings["myconn"].ToString();
    SqlConnection con = new SqlConnection(@CNS);
    SqlCommand sda = new SqlCommand("update profiles set department='"+txt_deptt.Text+"',qualifications='"+txt_qualificatns.Text+"', address='"+txt_add.Text+"', contacts='"+txt_contacts.Text+"', interests='"+txt_interests.Text+"', awards='"+txt_awards.Text+"', website='"+txt_website.Text+"', skills='"+txt_skills.Text+"', mstatus='"+txt_mstatus.Text+"' where username='" + Session["currentusername"].ToString() + "'", con);
    DataSet ds = new DataSet();
    try
    {
        con.Open();
        int temp=sda.ExecuteNonQuery();
        con.Close();
        if (temp >= 1)
        {
            lbl_message.ForeColor = System.Drawing.Color.Green;
            lbl_message.Text = "Profile Updated Successfully!";
        }
        else
        {
            lbl_message.ForeColor = System.Drawing.Color.Red;
            lbl_message.Text = "Integer less than 1";
        }

    }
    catch
    {
        lbl_message.ForeColor = System.Drawing.Color.Red;
        lbl_message.Text = "Try Again Later, An Error Occured!";
    }
    //Response.Redirect("profile.aspx");
}

}

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T07:15:30+00:00Added an answer on May 31, 2026 at 7:15 am

    You are overwriting the contents of your textboxes every time the page loads so the user inputted conntet is never written to the database…

    Look at the Page.IsPostBack method. Basically, wrap the commands to fill the textboxes with

    if (!Page.IsPostBack) {}
    

    To only load the values into the text box the first time the page loads (and so not overwrite the user entered values when you click the button you need to check that the page isn’t a post back.

    I think maybe a book on basic ASP.Net will help answer many questions you may have early on.

    protected void Page_Load(object sender, EventArgs e)
    {
     if (!Page.IsPostBack) {
        string CNS = ConfigurationManager.ConnectionStrings["myconn"].ToString();
        SqlConnection con = new SqlConnection(@CNS);
        SqlDataAdapter sda = new SqlDataAdapter("select * from profiles where username='" +     Session["currentusername"].ToString()+"'", con);
        DataSet ds = new DataSet();
        sda.Fill(ds, "profiles");
        txt_name.Text = ds.Tables["profiles"].Rows[0][0].ToString();
        txt_deptt.Text = ds.Tables["profiles"].Rows[0][1].ToString();
        txt_qualificatns.Text = ds.Tables["profiles"].Rows[0][2].ToString();
        txt_add.Text = ds.Tables["profiles"].Rows[0][3].ToString();
        txt_contacts.Text = ds.Tables["profiles"].Rows[0][4].ToString();
        txt_interests.Text = ds.Tables["profiles"].Rows[0][5].ToString();
        txt_awards.Text = ds.Tables["profiles"].Rows[0][6].ToString();
        txt_website.Text = ds.Tables["profiles"].Rows[0][7].ToString();
        txt_skills.Text = ds.Tables["profiles"].Rows[0][8].ToString();
        txt_mstatus.Text = ds.Tables["profiles"].Rows[0][9].ToString();
        ds.Reset();
    }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am developing an ASP.NET project with C#, and I wrote a page named
Our team is developing a rather big ASP.NET web project which initially started in
I am developing a C# VS 2008 / SQL Server 2008 ASP.NET Web Applications
I'm currently developing a C# app with an SQL Server DB back-end. I'm approaching
I'm developing an ASP.Net project. I have an <asp:Table> control on my page, to
I am in the middle of developing a project, which uses ASP.NET/C#. I am
I'm approaching the end of a C#/ASP.NET project I am developing, and I'll have
I am developing e-commerce project on Asp.Net 3.5 with C#. I am using 3
i have a problem i am developing an asp.net mvc project. Website is in
I am developing a medium sized ASP.NET project using ASP.NET MVC and Entity Framework.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.