Dreaded Failed to enable constraints!!

After wasting a few hours on this dang error, I thought I would post on here for some help!

OK, here's the code in error:

datagridBills.DataSource = Me.BillTableAdapter.GetDataByDateAs(e.Start.Date)

This is a datagrid and NOT a datagridview.

GetDataByDateAs: SELECT Bill_Name AS Name, Bill_Balance AS Balance,IsPaid, Bill_dueDate, Bill_ID FROM Bill WHERE Bill_dueDate = @date

Now, I don't understand why this works perfectly when I take out the "AS" from the sql query. It seems any little change to the standard sql query will cause problems.

I'm new to VB 2005, so go easy on me please :)



Answer this question

Dreaded Failed to enable constraints!!

  • Guiller

    "Name" is probably in conflict with a property called Name on something in your grid, possibly DataGridColumnStyle.DataGridColumnHeaderAccessibleObject.Name.

    You may be able to get around this by enclosing the word Name in braces []. Otherwise, you probably just need to choose something besides Name.

    Tony


  • Martijn Bakker

    Cmon guys! Someone out there must have other ideas!! I need to fix this :( Been at it all day... I'm about to give up and move on.
  • carda

    I am using Visual Studio 2005 and Crystal Reports..converted from Visual Studio 2003, it was a nightmare and this was one of the issues. You can avoid the error by setting the EnforceConstraints property of your DataSet to False

    _SubDataSet2.EnforceConstraints = False

    Also if you are using an .xsd file, check the properties and make sure the AllowDBNull property is set to False.

    Hope this helps!



  • Benyu

    I've been bit by this several times and finally hit on a solution that does not require changing my underlying stored procs or query at all. Go the GUI view of the TableAdapter and right-click on the column names that CAN be NULL in the database. View the properties and set AllowDBNull = true and NullValue to Empty. In my case the NullValue action was to throw an exception.


  • stuohy

    Thanks but no luck...

    Me.BillTableAdapter.GetDataByDateAs(e.Start.Date) -> Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints.

    When I check the results in the querybuilder everything appears OK. I don't understand why this wouldn't be working...

    I wonder if I catch the exception if I can tell what's going on.... this has got to be the most vague error in VB!


  • Dreaded Failed to enable constraints!!