Bonjour,
Pouvez vous me dire que signifie cette erreur et comment pourrai je la corriger svp??
A critical error has occurred.
The INSERT statement conflicted with the FOREIGN KEY constraint "FK__aspnet_Me__UserI__4F67C174". The conflict occurred in database "D:\INETPUB\DOSSIER DE SAUVEGARDE\VERSION SAUVGARDE 2\PROJET_ALIAS\APP_DATA\DATABASE.MDF", table "dbo.aspnet_Users", column 'UserId'. The statement has been terminated.
Je developpe en fait sous DotnetNuke et pour un besoin de creation d'un nouveau module d'enregistrement j'ai crée deux dataset : 1 pour ma base specifique et l'autre pour le bd dnn database et j'essaie d'inserer mes utilisateurs dans mes 2 bases de données.
Pour mon code
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
 protected void Button1_Click(object sender, EventArgs e)
    {
        ds_test ds_dnn = new ds_test();
        ds_test.aspnet_UsersRow aspuser = ds_dnn.aspnet_Users.Newaspnet_UsersRow();
        ds_test.aspnet_ApplicationsRow apli=ds_dnn.aspnet_Applications.Newaspnet_ApplicationsRow();
       ds_test.UsersRow u = ds_dnn.Users.NewUsersRow();
       ds_test.aspnet_MembershipRow asp = ds_dnn.aspnet_Membership.Newaspnet_MembershipRow();
    ds_enregistrement_candidat ds = new ds_enregistrement_candidat();
    ds_enregistrement_candidat.CandidatRow r = ds.Candidat.NewCandidatRow();
    ds_enregistrement_candidat.SituationActuelleRow s = ds.SituationActuelle.NewSituationActuelleRow();
    ds_enregistrement_candidat.FormationRow f = ds.Formation.NewFormationRow();
    ds_enregistrement_candidat.formationCandidatRow fc = ds.formationCandidat.NewformationCandidatRow(); 
    ds_enregistrement_candidat.ExperienceRow ex = ds.Experience.NewExperienceRow();
   u.Username = txt_email.Text;
   u.LastName = txt_nom.Text;
   u.IsSuperUser = false;
   u.Email = txt_email.Text;
   u.DisplayName = txt_prenom.Text;
   u.FirstName = txt_prenom.Text;
   u.UpdatePassword = false;
   asp.Email = txt_email.Text;
   asp.Password = mdp1.Text; 
        asp.PasswordFormat = 2;
        asp.PasswordSalt = mdp2.Text;
        asp.IsApproved=true;
        asp.IsLockedOut = false;
        asp.CreateDate = DateTime.Now;
        asp.LastLoginDate = DateTime.Now;
        asp.LastLockoutDate = DateTime.Now;
        asp.LastPasswordChangedDate = DateTime.Now;
        asp.FailedPasswordAnswerAttemptCount=0;
        asp.FailedPasswordAttemptWindowStart = DateTime.Now;
        asp.FailedPasswordAnswerAttemptCount =0;
        asp.FailedPasswordAnswerAttemptWindowStart = DateTime.Now;
        string monGuidStr ="5fa67d63-e30f-4b1e-b7eb-e9a204eba969";
        Guid g = new Guid(monGuidStr);
        asp.ApplicationId = g;
 
       int idc = r.idcandidat;
 
       Guid id = Guid.NewGuid();
       asp.UserId = id;
       //aspuser.UserId = asp.UserId;
        int ids;
        ids = s.idSituation;
        int idf = f.idFormation;
        fc.idFormation = idf;
        fc.idcandidat = idc;
        r.nom = txt_nom.Text;
        r.prenom = txt_prenom.Text;
        r.ville = txt_ville.Text;
 
        r.emailLogin = txt_email.Text;
        r.mdp = mdp1.Text;
        r._date = txt_date.Text;
 
        r.idSituation = ids;
 
        ds.Candidat.AddCandidatRow(r);
       ds_enregistrement_candidatTableAdapters.CandidatTableAdapter ta = new ds_enregistrement_candidatTableAdapters.CandidatTableAdapter();
        ta.Update(ds.Candidat);
 
        ds_dnn.Users.AddUsersRow(u);
        ds_testTableAdapters.UsersTableAdapter tu = new ds_testTableAdapters.UsersTableAdapter();
        tu.Update(ds_dnn.Users);
 
        ds_dnn.aspnet_Membership.Addaspnet_MembershipRow(asp);
        ds_testTableAdapters.aspnet_MembershipTableAdapter tasp = new ds_testTableAdapters.aspnet_MembershipTableAdapter();
        tasp.Update(ds_dnn.aspnet_Membership);
    }
Si vous pouvez m'aider n'hesitez pas j'en ai vraiment besoin.
Merci