Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Table UserId row population

Table UserId row population

Scheduled Pinned Locked Moved Database
asp-netsharepointdatabaseworkspace
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Member 9142936
    wrote on last edited by
    #1

    Hi there, I am fairly new to programming SP, I am trying to create a relationship between to tables in my database. The tables are aspnet_Membership and aspnet_Genealogy, I have setup a relation with the two tables using a PK in the table aspnet_Membership and a FK in the table aspnet_Genealogy as can be seen in the code below:

    CREATE TABLE [dbo].[aspnet_Genealogy] (
    [GenealogyId] INT IDENTITY (1, 1) NOT NULL,
    [UserId] UNIQUEIDENTIFIER NULL,
    [FamilyName] CHAR (200) NOT NULL,
    [FirstName] CHAR (200) NULL,
    [MiddleName1] CHAR (200) NULL,
    [MiddleName2] CHAR (200) NULL,
    [MiddleName3] CHAR (200) NULL,
    [Gender] CHAR (10) NULL,
    [DOB] VARCHAR (20) NOT NULL,
    [COB] CHAR (200) NULL,
    [SOB] CHAR (200) NULL,
    [COOB] CHAR (200) NULL,
    [Newsletter] CHAR (10) NULL,
    [DateTimeGenealogy] DATETIME NOT NULL,
    PRIMARY KEY CLUSTERED ([GenealogyId] ASC),
    CONSTRAINT [FK_aspnet_Genealogy_aspnet_Membership] FOREIGN KEY ([UserId]) REFERENCES [dbo].[aspnet_Membership] ([UserId])
    );

    and

    CREATE TABLE [dbo].[aspnet_Membership] (
    [ApplicationId] UNIQUEIDENTIFIER NOT NULL,
    [UserId] UNIQUEIDENTIFIER NOT NULL,
    [Password] NVARCHAR (128) NOT NULL,
    [PasswordFormat] INT DEFAULT ((0)) NOT NULL,
    [PasswordSalt] NVARCHAR (128) NOT NULL,
    [MobilePIN] NVARCHAR (16) NULL,
    [Email] NVARCHAR (256) NULL,
    [LoweredEmail] NVARCHAR (256) NULL,
    [PasswordQuestion] NVARCHAR (256) NULL,
    [PasswordAnswer] NVARCHAR (128) NULL,
    [IsApproved] BIT NOT NULL,
    [IsLockedOut] BIT NOT NULL,
    [CreateDate] DATETIME NOT NULL,
    [LastLoginDate] DATETIME NOT NULL,
    [LastPasswordChangedDate] DATETIME NOT NULL,
    [LastLockoutDate] DATETIME NOT NULL,
    [FailedPasswordAttemptCount]

    M 1 Reply Last reply
    0
    • M Member 9142936

      Hi there, I am fairly new to programming SP, I am trying to create a relationship between to tables in my database. The tables are aspnet_Membership and aspnet_Genealogy, I have setup a relation with the two tables using a PK in the table aspnet_Membership and a FK in the table aspnet_Genealogy as can be seen in the code below:

      CREATE TABLE [dbo].[aspnet_Genealogy] (
      [GenealogyId] INT IDENTITY (1, 1) NOT NULL,
      [UserId] UNIQUEIDENTIFIER NULL,
      [FamilyName] CHAR (200) NOT NULL,
      [FirstName] CHAR (200) NULL,
      [MiddleName1] CHAR (200) NULL,
      [MiddleName2] CHAR (200) NULL,
      [MiddleName3] CHAR (200) NULL,
      [Gender] CHAR (10) NULL,
      [DOB] VARCHAR (20) NOT NULL,
      [COB] CHAR (200) NULL,
      [SOB] CHAR (200) NULL,
      [COOB] CHAR (200) NULL,
      [Newsletter] CHAR (10) NULL,
      [DateTimeGenealogy] DATETIME NOT NULL,
      PRIMARY KEY CLUSTERED ([GenealogyId] ASC),
      CONSTRAINT [FK_aspnet_Genealogy_aspnet_Membership] FOREIGN KEY ([UserId]) REFERENCES [dbo].[aspnet_Membership] ([UserId])
      );

      and

      CREATE TABLE [dbo].[aspnet_Membership] (
      [ApplicationId] UNIQUEIDENTIFIER NOT NULL,
      [UserId] UNIQUEIDENTIFIER NOT NULL,
      [Password] NVARCHAR (128) NOT NULL,
      [PasswordFormat] INT DEFAULT ((0)) NOT NULL,
      [PasswordSalt] NVARCHAR (128) NOT NULL,
      [MobilePIN] NVARCHAR (16) NULL,
      [Email] NVARCHAR (256) NULL,
      [LoweredEmail] NVARCHAR (256) NULL,
      [PasswordQuestion] NVARCHAR (256) NULL,
      [PasswordAnswer] NVARCHAR (128) NULL,
      [IsApproved] BIT NOT NULL,
      [IsLockedOut] BIT NOT NULL,
      [CreateDate] DATETIME NOT NULL,
      [LastLoginDate] DATETIME NOT NULL,
      [LastPasswordChangedDate] DATETIME NOT NULL,
      [LastLockoutDate] DATETIME NOT NULL,
      [FailedPasswordAttemptCount]

      M Offline
      M Offline
      Mycroft Holmes
      wrote on last edited by
      #2

      Have you looked at the data (using SQL Server Management Studio) to find that the geneology table does not have the GUID in userid?

      DECLARE @UserId uniqueidentifier
      DECLARE @GenealogyId int

      IF ( @GenealogyId = +1 )

      @GenealogyId will always be 0 (or null), you have just created it, so your update statement is wrong before it starts. I suggest you get the userid GUID before you insert the genealogy record.

      Never underestimate the power of human stupidity RAH

      M 1 Reply Last reply
      0
      • M Mycroft Holmes

        Have you looked at the data (using SQL Server Management Studio) to find that the geneology table does not have the GUID in userid?

        DECLARE @UserId uniqueidentifier
        DECLARE @GenealogyId int

        IF ( @GenealogyId = +1 )

        @GenealogyId will always be 0 (or null), you have just created it, so your update statement is wrong before it starts. I suggest you get the userid GUID before you insert the genealogy record.

        Never underestimate the power of human stupidity RAH

        M Offline
        M Offline
        Member 9142936
        wrote on last edited by
        #3

        Hi There, Thank you for the quick response, I changed the GenealogyId to = NULL. It still doesn't work, I have never heard of guid. How does it work and how is the code implemented? Can you explain? Look forward to hearing from you soon. Thanks

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups