locked
Why is expects the parameter '@Photo2', which was not supplied RRS feed

  • Question

  • User1741069310 posted
                    strsql = "update people set ";
                    strsql += "[Full Name]=@FullName, ";
                    strsql += "[Chinese Name]=@Chinese_Name, ";
                    strsql += "Department ='" + DDDepartment.SelectedItem.Text + "', ";
                    strsql += "Section ='" + DDSection.SelectedItem.Text + "', ";
                    strsql += "Position ='" + Position.Text + "', ";
                    strsql += "[Ext.]='" + Extension.Text + "', ";
                    strsql += "email = '" + Email.Text + "', ";
                    strsql += "Photo=@Photo2 ,";
                    strsql += "Company ='" + DDCompany.SelectedItem.Text + "', ";
                    strsql += "Loginname ='" + Email.Text.Substring(0, Email.Text.IndexOf("@")) + "', ";
                    strsql += "IsLeave='N' ";
                    strsql += "where [Staff ID]=" + StaffID.Text;
     
     
                    cmd = new System.Data.SqlClient.SqlCommand();
                    cmd.Connection = con;
                    cmd.CommandType = CommandType.Text;
     
                    cmd.CommandText = strsql;
                    cmd.Parameters.AddWithValue("@FullName", FullName.Text);
                    cmd.Parameters.AddWithValue("@Chinese_Name", Chinese_Name.Text);
                    cmd.Parameters.AddWithValue("@Photo2", imgByte);

    Monday, November 26, 2018 5:29 AM

All replies

  • User1120430333 posted

    <div>                strsql = "update people set ";</div> <div>                strsql += "[Full Name]=@FullName, ";</div> <div>                strsql += "[Chinese Name]=@Chinese_Name, ";</div> <div>                strsql += "Department ='" + DDDepartment.SelectedItem.Text + "', ";</div> <div>                strsql += "Section ='" + DDSection.SelectedItem.Text + "', ";</div> <div>                strsql += "Position ='" + Position.Text + "', ";</div> <div>                strsql += "[Ext.]='" + Extension.Text + "', ";</div> <div>                strsql += "email = '" + Email.Text + "', ";</div> <div>                strsql += "Photo=@Photo2 ,";</div> <div>                strsql += "Company ='" + DDCompany.SelectedItem.Text + "', ";</div> <div>                strsql += "Loginname ='" + Email.Text.Substring(0, Email.Text.IndexOf("@")) + "', ";</div> <div>                strsql += "IsLeave='N' ";</div> <div>                strsql += "where [Staff ID]=" + StaffID.Text;</div> <div> </div> <div> </div> <div>                cmd = new System.Data.SqlClient.SqlCommand();</div> <div>                cmd.Connection = con;</div> <div>                cmd.CommandType = CommandType.Text;</div> <div> </div> <div>                cmd.CommandText = strsql;</div> <div>                cmd.Parameters.AddWithValue("@FullName", FullName.Text);</div> <div>                cmd.Parameters.AddWithValue("@Chinese_Name", Chinese_Name.Text);</div> <div>                cmd.Parameters.AddWithValue("@Photo2", imgByte);</div>

    And you expect someone to read that? The {;} icon on the toolbar before you make a post format's code properly before you submit the post.

    Monday, November 26, 2018 5:44 AM