SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Help with creating relationships
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Darkmatter5
Starting Member

17 Posts

Posted - 11/19/2012 :  11:20:39  Show Profile  Reply with Quote
I have two table both with a column named TypeID.

Paths <-table
TypeID (int, 4, primary key = no, identity = false)

Types <-table
TypeID (int, 4, primary key = yes, identity = true)

This is a SQL compact DB that I'm editing through Visual Studio. When I try and make a relationship between the two tables via the TypeID columns I get the following error.

"Add Relation failed. Parent Columns and Child Columns don't have type-matching columns."

Both are int with length 4, what could be causing this error?

TG
Flowing Fount of Yak Knowledge

USA
6059 Posts

Posted - 11/19/2012 :  11:56:01  Show Profile  Reply with Quote
I don't have too much to offer here but since no one else is chiming in -
Perhaps VS's schema is out of sync with the actual database or maybe pointing to a different db instance?

But being a long term sql server developer I only use Management Studio for this. For instance to create this "relationship" I would use a query window to issue this command:

alter table Paths add constraint FK_Paths_Types foreign key (TypeID) references Types (TypeID)

Can Sql Compact be used in SSMS?

Be One with the Optimizer
TG
Go to Top of Page

sodeep
Flowing Fount of Yak Knowledge

USA
7174 Posts

Posted - 11/19/2012 :  12:54:29  Show Profile  Reply with Quote
I think it might be due to identity column. Do you have some value in child table(Primary Key) which doesn't exist in Parent table?
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000