Unique constraint Bug ????

  • Thread starter João Santa Bárbara
  • Start date
J

João Santa Bárbara

Hi all

i have a problem with my sql dataadapter, i think.
i have this table below ( Script ) and this table has one particularity, it
has 2 unique constraints.

when i´m filling my datatable using my dataadapter, the datatable only have
one ???

is there any workarround for it, besides do it by code ???

thsk
JSB




CREATE TABLE [dbo].[xTable] (
[Test0] [char] (10) COLLATE Latin1_General_CI_AS NOT NULL ,
[Test1] [char] (10) COLLATE Latin1_General_CI_AS NULL ,
[Test2] [char] (10) COLLATE Latin1_General_CI_AS NULL ,
[Test3] [char] (10) COLLATE Latin1_General_CI_AS NULL ,
[Test4] [char] (10) COLLATE Latin1_General_CI_AS NULL
) ON [PRIMARY]
GO

ALTER TABLE [dbo].[xTable] ADD
CONSTRAINT [PK_xTable] PRIMARY KEY CLUSTERED
(
[Test0]
) ON [PRIMARY] ,
CONSTRAINT [IX_xTable] UNIQUE NONCLUSTERED
(
[Test0],
[Test1]
) ON [PRIMARY] ,
CONSTRAINT [IX_xTable_1] UNIQUE NONCLUSTERED
(
[Test2],
[Test3],
[Test4]
) ON [PRIMARY]
GO
 
P

Patrice

Which one is missing ?

If (test0) is unique, IMO (test0,test1) is necessarily unique or do I miss
something ?
(narrowed down to ADO.NET)
 
W

Willy Denoyette [MVP]

Please don't cross-post to non SQL related NG, post SQL questions to a SQL
related NG's like this portugese NG microsoft.public.pt.sql.

Willy.
 
J

João Santa Bárbara

Sorry Willy, but for the next time read the text carfully ...
instead of saying anything wrong ...

SEE ..... READ FROM HERESEE ..... TO HERE






Willy Denoyette said:
Please don't cross-post to non SQL related NG, post SQL questions to a SQL
related NG's like this portugese NG microsoft.public.pt.sql.

Willy.


João Santa Bárbara said:
Hi all

i have a problem with my sql dataadapter, i think.
i have this table below ( Script ) and this table has one particularity,
it has 2 unique constraints.

when i´m filling my datatable using my dataadapter, the datatable only
have one ???

is there any workarround for it, besides do it by code ???

thsk
JSB




CREATE TABLE [dbo].[xTable] (
[Test0] [char] (10) COLLATE Latin1_General_CI_AS NOT NULL ,
[Test1] [char] (10) COLLATE Latin1_General_CI_AS NULL ,
[Test2] [char] (10) COLLATE Latin1_General_CI_AS NULL ,
[Test3] [char] (10) COLLATE Latin1_General_CI_AS NULL ,
[Test4] [char] (10) COLLATE Latin1_General_CI_AS NULL
) ON [PRIMARY]
GO

ALTER TABLE [dbo].[xTable] ADD
CONSTRAINT [PK_xTable] PRIMARY KEY CLUSTERED
(
[Test0]
) ON [PRIMARY] ,
CONSTRAINT [IX_xTable] UNIQUE NONCLUSTERED
(
[Test0],
[Test1]
) ON [PRIMARY] ,
CONSTRAINT [IX_xTable_1] UNIQUE NONCLUSTERED
(
[Test2],
[Test3],
[Test4]
) ON [PRIMARY]
GO
 
W

Willy Denoyette [MVP]

João Santa Bárbara said:
Sorry Willy, but for the next time read the text carfully ...
instead of saying anything wrong ...

SEE ..... READ FROM HERE
SEE ..... TO HERE


NO I didn't say anything wrong, YOU should take care not to cross-post to
non relevant NG's. Your question is not Csharp nor VB (the languages)
related , it's about "adonet" and "SQL", so if you think you need to
cross-post restrict your posting to these NG's only.

Willy.
 
J

Jay B. Harlow [MVP - Outlook]

João,
| when i´m filling my datatable using my dataadapter, the datatable only
have
| one ???
Which unique constraints does it have?

PK_xTable
IX_xTable
IX_xTable_1

I suspect it only has PK_xTable.


| is there any workarround for it, besides do it by code ???
Did you let the DataAdapter define your DataTable or did you use an XSD or
code?

I suspect you let the DataAdapter

In your XSD or Code are you certain that you defined all constraints
correctly?

My understanding is: Seeing as you have a PrimaryKey, the DataAdapter will
only add the Primary Key constraint & leave the other two unique constraints
off. Based on the three rules at:

http://msdn.microsoft.com/library/d...datacommondataadapterclassfillschematopic.asp

I normally define my datatable schemas in an XSD file & either load that
directly first or have a typed DataSet.

For a complete explanation of Datasets, DataTables, & DataAdapters along
with how to use them. I would strongly recommend you read David Sceppa's
book "Microsoft ADO.NET - Core Reference" from MS Press. As it is both a
good tutorial on ADO.NET as well as a good desk reference once you know
ADO.NET.

Hope this helps
Jay



| Hi all
|
| i have a problem with my sql dataadapter, i think.
| i have this table below ( Script ) and this table has one particularity,
it
| has 2 unique constraints.
|
| when i´m filling my datatable using my dataadapter, the datatable only
have
| one ???
|
| is there any workarround for it, besides do it by code ???
|
| thsk
| JSB
|
|
|
|
| CREATE TABLE [dbo].[xTable] (
| [Test0] [char] (10) COLLATE Latin1_General_CI_AS NOT NULL ,
| [Test1] [char] (10) COLLATE Latin1_General_CI_AS NULL ,
| [Test2] [char] (10) COLLATE Latin1_General_CI_AS NULL ,
| [Test3] [char] (10) COLLATE Latin1_General_CI_AS NULL ,
| [Test4] [char] (10) COLLATE Latin1_General_CI_AS NULL
| ) ON [PRIMARY]
| GO
|
| ALTER TABLE [dbo].[xTable] ADD
| CONSTRAINT [PK_xTable] PRIMARY KEY CLUSTERED
| (
| [Test0]
| ) ON [PRIMARY] ,
| CONSTRAINT [IX_xTable] UNIQUE NONCLUSTERED
| (
| [Test0],
| [Test1]
| ) ON [PRIMARY] ,
| CONSTRAINT [IX_xTable_1] UNIQUE NONCLUSTERED
| (
| [Test2],
| [Test3],
| [Test4]
| ) ON [PRIMARY]
| GO
|
|
|
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top