Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0The INSERT statement conflicted with the FOREIGN KEY constraintThe INSERT statement conflicted with the FOREIGN KEY constraint
Previous
 
Next
New Post
6/3/2009 7:42 PM
 

Hello,

Please can you tell me what this error means and how can I fix it ?

 
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.

for creation of a new registration module I created two dataset: 1 for my specific DB and the other for the bd DNN database and I try to insert my users to my 2 databases


this is my code

Code :
 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);
    }
 
Please help me!!
  

 
New Post
6/4/2009 5:35 AM
 

 pelase do not try to access database tables directly from code, please use correct business layer API (dotnetnuke.entities.users and usercontroller).


Cheers from Germany,
Sebastian Leupold

dnnWerk - The DotNetNuke Experts   German Spoken DotNetNuke User Group

Speed up your DNN Websites with TurboDNN
 
New Post
6/4/2009 6:59 AM
 

Hi ,

Where Can I find this API please?

Thanks

 
Previous
 
Next
HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0The INSERT statement conflicted with the FOREIGN KEY constraintThe INSERT statement conflicted with the FOREIGN KEY constraint


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out