Msg 547, Level 16, State 0, Line 2
The INSERT statement conflicted with the FOREIGN KEY constraint "FK_Customer_Country". The conflict occurred in database "Customor", table "dbo.Country", column 'Country_ID'.
"""""""""""""""""""""""""""""""""""""""""""""""""" """"""
Need Help Pls
7 1879
It looks like you tried to enter a customer with an invalid country code
It would help if you posted your database structure and the insert statement that you used
Tnx for your reply Sir
Here is my table contains
Customer Table
----------------------
Customer_Id int Identity notnull (PrimaryKey)
fname varchar(30) notnull
lname varchar(40) notnull
Address varchar(100) notnull
City varchar(30) notnull
State varchar(20) notnull
Country tinyint Notnull {Relationship withCountry_code}
Postal varbinary(50) Null
Mugshot image Null
Acceptemail bit Null
Balance money Notnull
monthly_fee money NotNull My country Table Contains are
Country_code tinyint notnull {PrimaryKey}
Country_name varchar(50) notnull
Country Code I made a relationship with Country in Customer table.
PrimaryKey ForignKey
Country--------Customer
Country_Code-----Country Qoury I used are below
select * from [Customer]
insert into Customer
values(101, 'Migoo', 'Mike', '101 main str', 'wilam', 'Ca', '1889',0,null, 155.00, 25.00)
when I run the Query now I am getting a error message saying.. Msg 257, Level 16, State 3, Line 2
Implicit conversion from data type varchar to varbinary is not allowed. Use the CONVERT function to run this query.
when I try to save the tables another error saying
Unable to create relationship 'FK_Customer_Country'.
The ALTER TABLE statement conflicted with the FOREIGN KEY constraint "FK_Customer_Country". The conflict occurred in database "Customer", table "dbo.Country", column 'Country_code'.
PLS HELP ME SIR I Am DOING MY SCHOOL ASSIGNMENT END DATE IS ALL MOST NEAR....
Ahamed
Homework ? OK, as I said to my children, Ill help, but not do it for you!
First hint - what values are you inserting into which fields ?
You should quote them explicitly like this: -
insert into Customer (
-
Customer_Id , fname , lname , Address , City , State , Country , Postal , Mugshot , Acceptemail , Balance , monthly_fee
-
)
-
values(101, 'Migoo', 'Mike', '101 main str', 'wilam', 'Ca', '1889', 0, null, 155.00, 25.00)
-
your data does not match the fields
THE primary key is an Identity, which automatically generates the next number, so should not be mentioned in the list
The country code is a tinyint - what value are you giving ... and how big should it be ?
I hope these give you an idea how to fix your problem
Graham
Sir Tnx a lot for Taking ure valuable time I got the data into my table but Postal code apiers like '0x0000'I have given a value for it '1889'n I change the datatype to varchar (10),when i save my Customer table I am getting a error message saying {Customer' table
- Unable to create relationship 'FK_Customer_Country'.
The ALTER TABLE statement conflicted with the FOREIGN KEY constraint "FK_Customer_Country". The conflict occurred in database "Customer", table "dbo.Country", column 'Country_code'.
}
pls help to fix this issue....I hope u wont mind helping......
Tnx
Regards
Ahamed
Here are your mistakes that you need to fix: - Like gpl said, you don't specify what fields you're inserting into.
- Your postal code is of type VARBINARY but the data isn't binary
- Your country code is an integer but '123456' is not an integer, it's a string.
tnx for ure reply Mr rabit I came a cross with inserting data nw i am getting a error when i save the customer table {Customer' table
- Unable to create relationship 'FK_Customer_Country'.
The ALTER TABLE statement conflicted with the FOREIGN KEY constraint "FK_Customer_Country". The conflict occurred in database "Customer", table "dbo.Country", column 'Country_code'.
}
That could mean a number of things. We would need to see the alter table statement that you used.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: William |
last post by:
When is VS 2005 official release going to be.
|
by: kathy |
last post by:
Working in a form, I have an Iif statement where if a date is not
filled in, another field will show as a blank. If the date IS filled
in, the 2nd field will show its actual value. The following...
|
by: NeilH |
last post by:
Hello All
I was wondering if someone could offer a rather inexperienced person
some advice.
Im trying to get my asp page to look at an access data
I created the following query in access...
|
by: Alpha |
last post by:
I have a window Application. this.close(); doesn't stop and close my
application when I get an error. Instead it continues trying to execute the
following codes. What code do I need to the...
|
by: Greg |
last post by:
My app makes a call to a remote server (about which I know relatively
little) using Webclient.UploadData. This is done once every 51/2 mins
and is called by code within a worker thread. 95% of the...
|
by: Greg |
last post by:
My app makes a call to a remote server (about which I know relatively
little) using Webclient.DownloadData. This is done once every 51/2 mins
and is called by code within a worker thread. 95% of...
|
by: marklawford |
last post by:
Hi guys,
I'm getting the following error message when trying to run a MERGE
statement I'm putting together. The syntax looks right to me But i must
be missing something. The "srce" table...
|
by: John Shadel |
last post by:
I have the following setup:
1. ASP.NET 2.0 web app hosted on a web server (inetpub directory
hosting physical files of the web site on a different drive name, E:
than the SQL Server Instance,...
|
by: Steve |
last post by:
Hi All
I have a windows application (written in VB.net 2005) which I update via web
downloads to my clients computers
The downloaded file is saved in a subfolder until the next time the...
|
by: Steve |
last post by:
Hi guys,
I'm trying to upgrade TFS 2005 to TFS 2008 on a test server in
preparation for upgrading our live box. However, when I run the
install of 2008, I get the following error message:
...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
|
by: ryjfgjl |
last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
| |