Speedbit

It seems to be impossible to use the data source configuration wizard when you have multi column primary keys.

The following error occurred when I was trying to generate a dataset for a table which had a primary key over 2 columns:

---------------------------
Data Source Configuration Wizard
---------------------------
Failed to add relation(s).

An item with the same key has already been added.


---------------------------
OK
---------------------------

Any feedback would be nice. Thanks.


Re: Windows Forms Data Controls and Databinding Data Source Configuration Wizard - Multi column primary key

Luc Morin

Hi,

You should be able to add tables with multi-columns keys to DataSets.

I seem to remember this error message when I was working with Oracle and that one of my Foreign Key was somehow broken.

Is your table also part of FK relations

Luc





Re: Windows Forms Data Controls and Databinding Data Source Configuration Wizard - Multi column primary key

Speedbit

Hello Luc,

Thank you for your reply.

I have the following tables:

/*==============================================================*/

/* Table: PROPERTYGROUP */

/*==============================================================*/

create table PROPERTYGROUP (

GROUPNAME nvarchar(20) not null,

PROPERTYCODE nvarchar(10) not null,

constraint PK_PROPERTYGROUP primary key (GROUPNAME, PROPERTYCODE)

)

go

/*==============================================================*/

/* Table: PROPERTYGROUPSENTENCE */

/*==============================================================*/

create table PROPERTYGROUPSENTENCE (

GROUPNAME nvarchar(20) not null,

PROPERTYCODE nvarchar(10) not null,

SENTENCE_TEXTCODE nvarchar(40) not null,

constraint PK_PROPERTYGROUPSENTENCE primary key (GROUPNAME, PROPERTYCODE, SENTENCE_TEXTCODE)

)

go

/*==============================================================*/

/* Index: PROPERTYGROUPSENTENCE_FK */

/*==============================================================*/

create index PROPERTYGROUPSENTENCE_FK on PROPERTYGROUPSENTENCE (

GROUPNAME ASC,

PROPERTYCODE ASC

)

go

/*==============================================================*/

/* Index: PROPERTYGROUPSENTENCE2_FK */

/*==============================================================*/

create index PROPERTYGROUPSENTENCE2_FK on PROPERTYGROUPSENTENCE (

SENTENCE_TEXTCODE ASC

)

go

alter table PROPERTYGROUPSENTENCE

add constraint "FK__PROPERTYGROUPSENTENCE-PROPERTYGROUP" foreign key (GROUPNAME, PROPERTYCODE)

references PROPERTYGROUP (GROUPNAME, PROPERTYCODE)

go

There are a lot more tables but they all work well except for one which also references to the PropertyGroup table.

My guess is that the data configuration wizard tries to create a relation for every column so after creating one relation the second wont work becouse it gets the same name.





Re: Windows Forms Data Controls and Databinding Data Source Configuration Wizard - Multi column primary key

Luc Morin

Hi,

Could you try to change the name of the "FK__PROPERTYGROUPSENTENCE-PROPERTYGROUP" foreign key to something shorter and without double underscores and without hyphen I'm just wondering if this doesn't fool the designer.

Try a name such as "FKTest" just to see.

Luc





Re: Windows Forms Data Controls and Databinding Data Source Configuration Wizard - Multi column primary key

Speedbit

Hi,

I Have already did that, I also created a db with only these tables.

I resolved the problem by removing the double primary key and creating one ID to do the job.

create table PROPERTYGROUP (

GROUPNAME nvarchar(20) not null,

PROPERTYCODE nvarchar(10) not null,

PROPERTYGROUPID integer not null,

constraint PK_PROPERTYGROUP primary key (PROPERTYGROUPID)

)

go

alter table PROPERTYGROUPSENTENCE

add constraint "FK__PROPERTYGROUPSENTENCE-PROPERTYGROUP" foreign key (PROPERTYGROUPID)

references PROPERTYGROUP (PROPERTYGROUPID)

go