本文介绍了update语句与外键约束“fk_auto_part_details_hand_installation”冲突。冲突发生在数据库“db”,表“dbo.hand_installation”列中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

private void btn_Edit_Click(object sender, EventArgs e)
       {
             using (sd = new SqlCommand("update Auto_Part_Details set Value_Part= @Value_Part, Auto_Parts_id = @Auto_Parts_id, Repair_id = @Repair_id, New_Old_Part = @New_Old_Part ,Provider_id = @Provider_id , Installation_id = @Installation_id , Notes = @Notes where Job_Card = @Job_Card and Items_No = @Items_No", con))
                {
                    sd.Parameters.AddWithValue("@Items_No", txt_Items_No.Text);
                    sd.Parameters.AddWithValue("@Job_Card", txt_Job_card.Text);
                    sd.Parameters.AddWithValue("@Value_Part", txt_Value_Part.Text);
                    sd.Parameters.AddWithValue("@Auto_Parts_id",
                    Convert.ToInt32(CB_Auto_parts.SelectedValue));
                    sd.Parameters.AddWithValue("@Repair_id",
                    Convert.ToInt32(CB_Repair_type.SelectedValue));
                    sd.Parameters.AddWithValue("@New_Old_Part", Convert.ToBoolean(x));
                    sd.Parameters.AddWithValue("@Provider_id",
                    Convert.ToInt32(CB_Providers_desc.SelectedValue));
                    sd.Parameters.AddWithValue("@Installation_id",
                    Convert.ToInt32(CB_Hand_installation.SelectedValue));
                    sd.Parameters.AddWithValue("@Notes", txt_Notes.Text);
                }
       }





我的尝试:



当这些组合框值之一为null时,如果我能解决这个问题就会发生这个错误



What I have tried:

this error happen when one of these combobox value is null how i can solve this problem

推荐答案



这篇关于update语句与外键约束“fk_auto_part_details_hand_installation”冲突。冲突发生在数据库“db”,表“dbo.hand_installation”列中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-30 21:57