Click here to Skip to main content
13,294,840 members (61,188 online)
Rate this:
Please Sign up or sign in to vote.
See more:
This is my update button code
protected void Save_Button_Click(object sender, EventArgs e)
           if (Page.IsPostBack)
               string Employee_id = Request.QueryString["Emp_Id"];
               SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["UsersManagerConnectionString"].ConnectionString);
               SqlCommand cmd = new SqlCommand("Update Employees Set First_Name='" + First_NamTextBox.Text + "' ,Last_Name='" + Last_NamTextBox.Text + "', Email='" + Email_TextBox.Text + "', Mobile_Number='" + Mobile_TextBox.Text + "' where Emp_Id='" + Employee_id + "'", con);
               int executequery = cmd.ExecuteNonQuery();
               if (executequery == 1) { Response.Redirect("MainAdmin.aspx"); }


Help me please.
Posted 26-Jan-13 2:38am
Updated 26-Jan-13 4:43am

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Check your Employee_id value - I suspect it is not matching any existing records. You don't show where you load it, but I suspect you will find it is empty.

And do not concatenate strings to build a SQL command. It leaves you wide open to accidental or deliberate SQL Injection attack which can destroy your entire database. Use Parametrized queries instead.

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web03 | 2.8.171207.1 | Last Updated 26 Jan 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100