Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Failed to enable constraints. One or more rows contain values violatin

Status
Not open for further replies.

ralphiooo

Programmer
Oct 23, 2005
64
GB
Hi, why do i keep getting the following:

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

come up when trying to use the table adapter.

I found an article at
to displays any constraint errors and adapted to my application:

Code:
Dim myDataSet As New KIT
Dim rowsInError() As Data.DataRow
Dim myTable As Data.DataTable
Dim i As Integer
Dim myCol As Data.DataColumn

For Each myTable In myDataSet.Tables
  ' Test if the table has errors. If not, skip it.
  If myTable.HasErrors Then
    ' Get an array of all rows with errors.
    rowsInError = myTable.GetErrors()

    ' Print the error of each column in each row.
    For i = 0 To rowsInError.GetUpperBound(0)
      For Each myCol In myTable.Columns
        Response.Write(myCol.ColumnName & " " & rowsInError(i).GetColumnError(myCol))
      Next

      ' Clear the row errors
      rowsInError(i).ClearErrors()
    Next i
  End If
Next

but nothing gets displayed.  Appreciate if someone could tell me what is wrong with my script above.

Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top