erreur d'ajout d'une ligne dans une table contient un clé etrangere
bonsoir
je travaille sous vs2008 + silverlight3 en c#
j'ai cree une base de Donnes dans sql server 2008 contient 2 tables:
table 1: Activity ( cle Primaire ActivityID)
table 2: Champ (clé primaire ChampID et contient un cle etrangere ActivityID, c'est le clé primaire du table Activity)
Alors j'utilise ADO.net pour acceder a ces 2 tables a partir de mon projet silverlight a partir du serveur web WCF :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
| [OperationContract]
public void AddChampLigne(String idAct, String idChamp, String TypeChamp, String ValueChamp, String laValeurDuValue)
{
using(BISDonnesEntities db=new BISDonnesEntities())
{
Champ ajoutChamp = new Champ()
{
ActivityID = idChamp,
ID = idAct,
Value = ValueChamp,
};
db.AddToChamp(ajoutChamp);
db.AcceptAllChanges();
} |
et dans ma page je fait l'appel de cette méthode mais il ' y a toujours une erreur pourtant que la table Activity contient une ligne de ActivityID=1 et lorsque je fait
Code:
1 2 3
| Service.monService1Client client = new EssaiLoadFRomXML.Service.monService1Client();
client.AddChampLigneAsync("1", "1","ines");
client.AddChampLigneCompleted += new EventHandler<System.ComponentModel.AsyncCompletedEventArgs>(client_AddChampLigneCompleted); |
et dans la methode client_AddChampLigneCompleted() :
Code:
1 2 3 4
| void client_AddChampLigneCompleted(object sender, System.ComponentModel.AsyncCompletedEventArgs e)
{
MessageBox.Show(e.Error.ToString());
} |
il'ya tjours une erreur qui s'affiche et pas d'ajout dans la table Champ