Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 243
  • Last Modified:

VB .Net and Datasets

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
Alfredo Luis Torres Serrano
Asked:
Alfredo Luis Torres Serrano
1 Solution
 
James MurrellProduct SpecialistCommented:
0
 
Bob LearnedCommented:
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
 
Alfredo Luis Torres SerranoAuthor Commented:
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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now