• Home
  • About
  • Resume

Cheat for “These columns don’t currently have unique values” error

By , 02/22/2011 11:20 AM

Ordinary when you create a parent-child relationship between DataTables in a DataSet – there is a requirement that all values of the parent columns need to be unique. If they’re not – you will get an error: “These columns don’t currently have unique values“.

But there’re times when you need to make the relationship work even if those values are not unique. The solution is not to create constrain when creating the relationship. This can be done for example by passing FALSE as value for createConstrains parameter of Dataset.Relations.Add method:

oMyDataSet.Relations.Add("MyRel", _
oMyDataSet.Tables("TheParent").Columns("ParentColumn"), _
dtSet.Tables("TheChild").Columns("ChildColumn"), _
False)

14 Responses to “Cheat for “These columns don’t currently have unique values” error”

  1. Levent KAYA says:

    Hi Yuri,
    Thank you very much for this solution.

  2. olga says:

    Thanks! you saved my weekend

  3. Yoga Herawan says:

    I say thank you for you because you had shared this solutions.
    ๐Ÿ™‚

  4. ninja says:

    WOW. ๐Ÿ™‚ Super thank you to you dude ๐Ÿ™‚

  5. Fabiรกn says:

    Thank’s from CUBA my friend Yuriy.

  6. SJ says:

    Amazing Yuriy. Thanx!

  7. joniemors says:

    Idol na talga kita.. The best ka..You save my day.

  8. Chirag says:

    Thank you very much ………

  9. ravi says:

    i need avoid datagridview duplicate row pls give some suggestion for that

  10. Yuriy says:

    @ravi I suggest eliminate duplicates at the source before you bind data to the grid. E.g. if you’re running a SELECT statement – do a SELECT DISINCT – this is oversimplification, but that’s the idea – eliminate duplicates before they hit the grid.

  11. idrees says:

    Thanx a lot dear

  12. rohit says:

    Thanks a lot dear

  13. Santosh Yadav says:

    Thanks a lot sir

  14. hiren says:

    thanks buddy.

Leave a Reply

Panorama Theme by Themocracy