title: SqlException: The INSERT statement conflicted with the FOREIGN KEY constraint "FK_Register_Event"
body: <p>I have three tables in SQL server;</p>
  
  <p><strong>Event</strong> table:</p>
  
  <pre><code>CREATE TABLE [dbo].[Event] 
  (
      [EventName]   VARCHAR(25) NOT NULL,
      [Description] VARCHAR(60) NULL,
      [Location]    VARCHAR(20) NULL,
      [Date]        VARCHAR(10) NULL,
      [TicketFee]   FLOAT(53)   NULL,
      PRIMARY KEY CLUSTERED ([EventName] ASC)
  );
  </code></pre>
  
  <p><strong>Client</strong>:</p>
  
  <pre><code>CREATE TABLE [dbo].[Client] 
  (
      [Email]    VARCHAR(35) NOT NULL,
      [FullName] VARCHAR(25) NULL,
      [Address]  VARCHAR(50) NULL,
      [Age]      INT          NULL,
      [Phone]    VARCHAR(15) NULL,
      PRIMARY KEY CLUSTERED ([Email] ASC)
  );
  </code></pre>
  
  <p><strong>Register</strong>:</p>
  
  <pre><code>CREATE TABLE [dbo].[Register] 
  (
      [Id]            INT         NOT NULL,
      [GuestNum]      INT         NULL,
      [PaymentAmount] FLOAT(53)   NULL,
      [EventName]     VARCHAR(25) NULL,
      [Email]         VARCHAR(35) NULL,
  
      PRIMARY KEY CLUSTERED ([Id] ASC),
      CONSTRAINT [FK_Register_Client] 
           FOREIGN KEY ([Email]) REFERENCES [dbo].[Client] ([Email]),
      CONSTRAINT [FK_Register_Event] 
           FOREIGN KEY ([EventName]) REFERENCES [dbo].[Event] ([EventName])
  );
  </code></pre>
  
  <p>The <code>Event</code> table consists of dummy data for search function only, and when a user tries to register a new event, it is stored in Register table.</p>
  
  <p>Trouble is that I am getting an error:</p>
  
  <blockquote>
    <p>SqlException: The INSERT statement conflicted with the FOREIGN KEY constraint "FK_Register_Event". The conflict occurred in database "C:\USERS\RHYME\SOURCE\REPOS\ONLINEEVENTREGISTRATION\ONLINEEVENTREGISTRATION\APP_DATA\DATABASE1.MDF", table "dbo.Event", column 'EventName'.</p>
  </blockquote>
  
  <p>I searched Internet and learned that it's because I'm trying to insert a record with a value in the foreign key column that doesn't exist in the foreign table. However even if I try to register an event with a different <code>EventName</code> that does not exist in the Event table it still throws the same error.</p>
  
  <p>I'm really confused where in my table is causing the problem...I'm new to database and any help would be appreciated.</p>