473,471 Members | 1,785 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

The INSERT statement conflicted with the FOREIGN KEY constraint

13 New Member
Hi

i have two tables

1- Person
2- Account

In Account table i have key accountID which is a FK in Person table.

when i run the insert query as


insert into

Person(FirstName2)

values ('waq')

as i did not enter any data for account field so it gives me the eror:


The INSERT statement conflicted with the FOREIGN KEY constraint "FK_Person_Account". The conflict occurred in database "abc", table "dbo.Account", column 'AccountId'.

can somebody help me with that as i want to insert the valuse in Person table whether i have accountID or not

Thanx
Nov 20 '09 #1

✓ answered by ssnaik84

since, you are having FK of AccountID in Person table, you must have related record in Account table.
I suggest you to insert a default record into Account table and use it's ID (AccountID) into Person table as default.

1 2007
ssnaik84
149 New Member
since, you are having FK of AccountID in Person table, you must have related record in Account table.
I suggest you to insert a default record into Account table and use it's ID (AccountID) into Person table as default.
Nov 20 '09 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: postings | last post by:
Hi I'm trying to port some data from one database table to another database table on the same server. This is the query I am using: -----> INSERT into newdatabase.dbo.contactevents ...
1
by: nomorems | last post by:
I was trying to copy a range of records from a table to the same table with a small modification. I was wondering why this takes a long time compared to just doing a subselect from that table and...
2
by: trint | last post by:
I am trying to insert a record, but I have to get an automatically created identity field at the same time to do this. string strSQL2 = "INSERT INTO tblTravelDetail(MemberID, " + "...
7
by: trint | last post by:
This: string strSQL2 = "INSERT INTO tblTravelDetailMember(memberId, " + " TravelDetailUplineId, " + " rankId, " + " TravelDetailId, " + " CreatedDateTime, " + " Operator) " + "VALUES ('" +...
2
by: Tim::.. | last post by:
Can someone please tell me why I keep getting the following error from the code below! Error: INSERT statement conflicted with COLUMN FOREIGN KEY constraint...
0
by: macupryk | last post by:
{System.Data.SqlClient.SqlException: The INSERT statement conflicted with the FOREIGN KEY constraint "FK_ProjectResponse__ProjectQuestionId". The conflict occurred in database "RG_ProjectData", table...
0
by: Robert Bravery | last post by:
HI all, VS 2005 C# MSSQL2005 I have a parent child grandchild related tables. Claimheader, claim (deteails), claimfinancialloss When ever I try to add row to claimfinancialloss table, I get...
3
by: weird0 | last post by:
I have two tables accounts and ATM and i am trying to insert a tuple in ATM with accountId as foreign key. But even this simple work,I encounter the following error: The INSERT statement...
3
by: haiminnu | last post by:
I have created Two tables 1]EmployeeTable -------------------------- EmpID EmpName AccessLevelID ...
2
by: ksenthilbabu | last post by:
Hey All, I am using MSSQL -2005 with VB6. I have created a master table tblCompany and detail Table tblDetail having foreign key relationship. When i try to insert a value within a TRANSACTION I...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.