Click here to Skip to main content
11,582,850 members (72,259 online)
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 1:38am
Edited 26-Jan-13 3:43am
ProgramFOX159.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 335
1 Sergey Alexandrovich Kryukov 220
2 Andy Lanng 124
3 virusstorm 109
4 Kornfeld Eliyahu Peter 90
0 OriginalGriff 1,358
1 Sergey Alexandrovich Kryukov 970
2 Abhinav S 671
3 F-ES Sitecore 505
4 Suvendu Shekhar Giri 448


Advertise | Privacy | Mobile
Web03 | 2.8.150603.1 | Last Updated 26 Jan 2013
Copyright © CodeProject, 1999-2015
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