saifullah khan

saifullah khan

  • NA
  • 335
  • 300.7k

primary forgien key error

May 27 2011 2:17 AM
i have created two database tables.
1.town(town id as pk,town name)
2. phase(phase id,town id, phase name. phase id and town id are composite keys)

then i created a web form consists o textbox named as phase id, dropdown name as townid that takes town id from table 1, and textbox named as phase name. textbx 1 i enter phase id, select town from drop drown and enter the phase name. when i click on submit i give me the follwoing error

Exception Details: System.Data.SqlClient.SqlException: The INSERT statement conflicted with the FOREIGN KEY constraint "FK_Phase_Town". The conflict occurred in database "pda_rtc", table "dbo.Town", column 'TownID'.
The statement has been terminated.
how do i solve this problem????


Answers (12)