Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

VB .Net and Datasets

Posted on 2008-06-25
3
Medium Priority
?
242 Views
Last Modified: 2013-11-26
Hi Experts,

  I have a combobox control  that have a datasource created with the datasource wizard and basiccly is:

SELECT DISTINCT '-Seleccione-' As Login FROM CMS
Union All
SELECT Distinct rtrim(Login) FROM CMS WHERE Convert(Smalldatetime,Fecha,103) Between Convert(Smalldatetime,@FechaI,103) And Convert(Smalldatetime,@FechaF,103) Order By login Desc

After i call
CMSTableAdapter.Fill(Db_AsistenciaDataSet.CMS, Format(DateTimePicker1.Value, "dd/MM/yyyy"), Format(DateTimePicker2.Value, "dd/MM/yyyy"))
An exception is  thrown telling me:
Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints
But the dataset is filled (The combobox is filled).

Any idea
Thanks


        CMSTableAdapter.Fill(Db_AsistenciaDataSet.CMS, Format(DateTimePicker1.Value, "dd/MM/yyyy"), Format(DateTimePicker2.Value, "dd/MM/yyyy"))

An exception is theown telling me that:

Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints

But the combobox is filled.

Any idea?
Thanks



0
Comment
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 31

Expert Comment

by:James Murrell
ID: 21872534
0
 
LVL 96

Accepted Solution

by:
Bob Learned earned 750 total points
ID: 21874191
All that means is that you have duplicate key values in your data.  You can disable constraints for the DataSet:

Db_AsistenciaDataSet.EnableConstraints = False
0
 
LVL 12

Author Closing Comment

by:Alfredo Luis Torres Serrano
ID: 31470697
cs97jjm3: None of the 3 cases expained on you post is my case i just have one table and that table does not have any key field and all field accept nulls and the query runs perfect on a query window.

TheLearnedOne: I have no keys on that table but your post help me to find a solution that was:

        Db_AsistenciaDataSet.EnforceConstraints = False just before fill the dataset.

Thanks
0

Featured Post

Automating Terraform w Jenkins & AWS CodeCommit

How to configure Jenkins and CodeCommit to allow users to easily create and destroy infrastructure using Terraform code.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
It is possible to export the data of a SQL Table in SSMS and generate INSERT statements. It's neatly tucked away in the generate scripts option of a database.
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question