Steve Brock

Steve Brock

  • NA
  • 9
  • 0

primary and foreign key

Jul 21 2007 3:53 PM

Hello

I'm using C# 2005 as a front end to SQL Server Express 2005.

I have two tables tblFSE and tblStatus. I want the tblFSE to be the main table for my form and tblStatus to be bound with a combobox on the main form. The combobox is to have 3 choices - Opened, In Progress and closed. They will be stored in the description field of tblStatus. On the form I want the combobox tied to pkStatus field.

So far I have...

tblFSE

IDFSE     int      primary key

FSEName varchar(50)

Customer varchar(50)

Date       date/time

pkStatus varchar(50)

Comment varchar(150)

 

tblStatus

IDStatus    int  primary key

description varchar(50)

 

So I'm trying to set up the relationship and am using

Primary key table      Foreign key table

tblFSE                    tblStatus

IDFSE                    IDStatus

 

All are type int but I’m getting the error…

 

'tblFSE' table saved successfully

'tblStatus' table

- Unable to create relationship 'FK_tblStatus_tblFSE'. 

The ALTER TABLE statement conflicted with the FOREIGN KEY constraint "FK_tblStatus_tblFSE". The conflict occurred in database "dbFSE", table "dbo.tblFSE", column 'IDFSE'.

 

Any ideas?

I’ve tried to match data types.

Please help

 

Regards,

Steve


Answers (4)