Solved

VB .Net and Datasets

Posted on 2008-06-25
3
236 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
3 Comments
 
LVL 31

Expert Comment

by:James Murrell
ID: 21872534
0
 
LVL 96

Accepted Solution

by:
Bob Learned earned 250 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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.

810 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