Solved

VB .Net and Datasets

Posted on 2008-06-25
3
234 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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

746 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now