Unique constraint Bug ????

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • João Santa Bárbara

    #1

    Unique constraint Bug ????

    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



  • Willy Denoyette [MVP]

    #2
    Re: Unique constraint Bug ????

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

    Willy.


    "João Santa Bárbara" <joaosb@i24port ugal.com> wrote in message
    news:uKoUkycnFH A.3408@tk2msftn gp13.phx.gbl...[color=blue]
    > 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
    >
    >
    >[/color]


    Comment

    • João Santa Bárbara

      #3
      Re: Unique constraint Bug ????

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

      SEE ..... READ FROM HERE[color=blue][color=green]
      >> 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 ???[/color][/color]
      SEE ..... TO HERE






      "Willy Denoyette [MVP]" <willy.denoyett e@telenet.be> wrote in message
      news:%23ek2WGen FHA.3900@TK2MSF TNGP09.phx.gbl. ..[color=blue]
      > Please don't cross-post to non SQL related NG, post SQL questions to a SQL
      > related NG's like this portugese NG microsoft.publi c.pt.sql.
      >
      > Willy.
      >
      >
      > "João Santa Bárbara" <joaosb@i24port ugal.com> wrote in message
      > news:uKoUkycnFH A.3408@tk2msftn gp13.phx.gbl...[color=green]
      >> 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
      >>
      >>
      >>[/color]
      >
      >[/color]


      Comment

      • Willy Denoyette [MVP]

        #4
        Re: Unique constraint Bug ????



        "João Santa Bárbara" <joaosb@i24port ugal.com> wrote in message
        news:u53FlclnFH A.2904@TK2MSFTN GP14.phx.gbl...[color=blue]
        > Sorry Willy, but for the next time read the text carfully ...
        > instead of saying anything wrong ...
        >
        > SEE ..... READ FROM HERE[color=green][color=darkred]
        >>> 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 ???[/color][/color]
        > SEE ..... TO HERE
        >[/color]


        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.


        Comment

        • Jay B. Harlow [MVP - Outlook]

          #5
          Re: Unique constraint Bug ????

          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/de...chematopic.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



          "João Santa Bárbara" <joaosb@i24port ugal.com> wrote in message
          news:uKoUkycnFH A.3408@tk2msftn gp13.phx.gbl...
          | 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
          |
          |
          |


          Comment

          Working...