fatal error encountered during command execution during update

后端 未结 1 1898
粉色の甜心
粉色の甜心 2021-01-24 17:42

i use this code to update data that are in the textboxes... this code is in the update button and once i made the changes and clicked the button the error message

相关标签:
1条回答
  • 2021-01-24 18:03

    Check in This Line

                cmd.Parameters.Clear();
    
                cmd.CommandText = "UPDATE contacts SET EMAIL = @EMAIL,
                CELL_NO = @CELL_NO Where STUDENT_NO = @STUDENT_NO";
    
                cmd.Parameters.AddWithValue("@EMAIL", email_txt.Text);
                cmd.Parameters.AddWithValue("@CELL_NO", contact_txt.Text);
                cmd.ExecuteNonQuery();
                cmd.Parameters.Clear();
    

    Change To

                cmd.Parameters.Clear();
                cmd.CommandText = "UPDATE contacts SET EMAIL = @EMAIL,
                CELL_NO = @CELL_NO Where STUDENT_NO = @STUDENT_NO";
    
                cmd.Parameters.AddWithValue("@EMAIL", email_txt.Text);
                cmd.Parameters.AddWithValue("@CELL_NO", contact_txt.Text);
                cmd.Parameters.AddWithValue("@STUDENT_NOL",studentNo_txt.Text);
                cmd.ExecuteNonQuery();
                cmd.Parameters.Clear();
    

    you are clear the parameters, but after that use @STUDENT_NO parameter. This parameter is not declare any where after clear ther parameters

    0 讨论(0)
提交回复
热议问题