Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#4.0
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);
                con.Open();
                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"); }
                con.Close();
            }
            
            
        }
Help me please.
Posted 26-Jan-13 2:38am
Edited 26-Jan-13 4:43am
ProgramFOX127.6K
v2

1 solution

Rate this: bad
good
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.
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 6,803
1 Sergey Alexandrovich Kryukov 6,377
2 DamithSL 5,421
3 Manas Bhardwaj 4,841
4 Maciej Los 4,330


Advertise | Privacy | Mobile
Web04 | 2.8.1411023.1 | Last Updated 26 Jan 2013
Copyright © CodeProject, 1999-2014
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