Problème d' Insertion dans deux tables au meme temps

hanounaTSDI Messages postés 1 Date d'inscription dimanche 24 septembre 2006 Statut Membre Dernière intervention 23 octobre 2006 - 23 oct. 2006 à 23:45
ahmani24 Messages postés 39 Date d'inscription mardi 13 avril 2004 Statut Membre Dernière intervention 14 novembre 2006 - 25 oct. 2006 à 01:57
slt,j'ai un problème d'ajout,c' une gestion de stock,g une table CommandeInterne(NumCInt,DatCInt,NumEm) et ligne-Commande_Interne(NumCInt,NumArt,QttéCInt) ils sont liés par la clé numeroCommandeInterne(NumCInt) ,g fais 1 formulaire qui contient le NumCInt,DateCInt,DesArt,QttéCom,NomEm alors à l'ajout d'une nouvelle Commande je dois inserer ces informations ds les deux tables et au meme temps .mé ca marche ps l'erreur c' tjs qu'il y a un conflit  entre l'instruction insert et la contrainte column foreign_key FK_LigneCommandeInterne_CommandeInterne.SVP si vous avez une solution,ca sera gentil de votre part,merci,et voici le code ke g ecris.



cmd.Connection = cn
cmd.CommandType = CommandType.Text

Try



cmd.commandText = "insert into CommandeInterne(NumCInt,DatCInt,NumEm) values('" & Tnum.Text & "','" & dp2.Value.Date & "'," & dt.Rows.Item(cb3.SelectedIndex).Item(0) & ")"





cmd.ExecuteNonQuery()



cmd.CommandText = "insert into Ligne_Com_Int(NumCInt,NumArt,QttéCInt) values ('" & Tnum.Text & "','" & dt.Rows.Item(cb2.SelectedIndex).Item(0) & "'," & T2.Text & ")"



cmd.ExecuteNonQuery()



MessageBox.Show("Ajout effectué avec succées")




Catch
ex

As



Exception





MessageBox.Show(ex.Message)



MessageBox.Show(ex.StackTrace)

End



Try

NB   :   dp2: contient la date, cb2:contient la designation d'article(desArt),cb3:contient le nom d'emargement(NomEm)

1 réponse

ahmani24 Messages postés 39 Date d'inscription mardi 13 avril 2004 Statut Membre Dernière intervention 14 novembre 2006
25 oct. 2006 à 01:57
Ton code marche tres bien
0
Rejoignez-nous