如何修改包含外键的表 [英] How to modify a table containing a foreign key

查看:286
本文介绍了如何修改包含外键的表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hi friends,
I have a table named "bon récéption " and which contains a foreign key Id_marche and in the interface of "bon récéption " I filled the combobox of the "libélllé marche"short market the problem is in button modify when I want to modify gives me this error
I will extract here my code and the error
thank you in advance





我尝试过:





What I have tried:

Program.cmd.CommandText = "update bon_reception_marche set Id_marche = (select distinct Id_marche from marche where Libelle_marche = '" + comboBox3.Text + "') ,Designation_bon_reception ='" + textBox2.Text + "',Num_bon_reception='" + textBox1.Text + "',Date_reception ='" + dateTimePicker1.Value.Date + "',Unite ='" + textBox3.Text + "',Qte= " + Convert.ToDouble(textBox4.Text) + ",Prix_unitaire=" + Convert.ToDouble(textBox5.Text) + ",Montant =" + Convert.ToDouble(textBox6.Text) + ",TVA =" + Convert.ToDouble(comboBox1.Text) + ",MO ='" + textBox8.Text + "',OT ='" + textBox9.Text + "' where Id_bon_reception_marche ="+textBox7.Text;







erreur




erreur

Le format de la chaîne d'entrée est incorrect.

推荐答案

错误信息,输入字符串的格式不正确,非常清楚。您的更新命令包含错误。你需要调试并弄清楚出了什么问题。



另外,你永远不应该使用字符串连接来构建SQL命令。在谷歌搜索参数化查询sql server。学会爱他们并且总是使用它们。
The error message,The format of the input string is incorrect, is very clear. Your update command contains an error. You need to debug and figure out what is wrong.

Also you should never, and I mean never, use string concatenation to build SQL command. Search google for "parameterized queries sql server". Learn to love them and always use them.


这篇关于如何修改包含外键的表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆