C
cs_in_va
I get the following error when trying to access a page (prodcuts.aspx)
with a single drop down list box bound to a objectdata source linked
to my categoryBLL,.vb file. Here is what I have.
Table Categories with CategoryId and CategoryName.
My DAL for this is very simple again:
SELECT CategoryID, CategoryName, Image
FROM Categories
Have a categoryBLL with the following code:
Imports ADAHSTableAdapters
<System.ComponentModel.DataObject()> _
Public Class CategoriesBLL
Private _categoriesAdapter As CategoriesTableAdapter = Nothing
Protected ReadOnly Property Adapter() As CategoriesTableAdapter
Get
If _categoriesAdapter Is Nothing Then
_categoriesAdapter = New CategoriesTableAdapter()
End If
Return _categoriesAdapter (error line)
End Get
End Property
<System.ComponentModel.DataObjectMethodAttribute(System.ComponentModel.DataObjectMethodType.Select,
True)> _
Public Function GetCategories() As ADAHS.CategoriesDataTable
Return Adapter.GetCategories()
End Function
<System.ComponentModel.DataObjectMethodAttribute(System.ComponentModel.DataObjectMethodType.Select,
False)> _
Public Function GetCategoryByCategoryID(ByVal categoryID As
Integer) As ADAHS.CategoriesDataTable
Return Adapter.GetCategoriesByCategoryID(categoryID)
End Function
End Class
Error Message on aspx page:
Failed to enable constraints. One or more rows contain values
violating non-null, unique, or foreign-key constraints.
Description: An unhandled exception occurred during the execution of
the current web request. Please review the stack trace for more
information about the error and where it originated in the code.
Exception Details: System.Data.ConstraintException: Failed to enable
constraints. One or more rows contain values violating non-null,
unique, or foreign-key constraints.
Source Error:
Line 2931: Me.Adapter.SelectCommand =
Me.CommandCollection(0)
Line 2932: Dim dataTable As ADAHS.CategoriesDataTable = New
ADAHS.CategoriesDataTable
Line 2933: Me.Adapter.Fill(dataTable)
Line 2934: Return dataTable
Line 2935: End Function
Stack Trace:
[ConstraintException: Failed to enable constraints. One or more rows
contain values violating non-null, unique, or foreign-key
constraints.]
.....More stuff,
CategoriesBLL.GetCategories() in C:\DNN_Web_Dev\ADAHS\App_Code\BLL
\CategoriesBLL.vb:18
Now when I preview the data in my tableadapter (categoriesDataTable) I
have no problem everything is displayed properly, but when I try and
link the Drop Down List to it I get the same error. I have tried not
using the BLL file and get the same error. Line 18 is "Return
_categoriesAdapter"
So where am I going wrong?
Thanks
with a single drop down list box bound to a objectdata source linked
to my categoryBLL,.vb file. Here is what I have.
Table Categories with CategoryId and CategoryName.
My DAL for this is very simple again:
SELECT CategoryID, CategoryName, Image
FROM Categories
Have a categoryBLL with the following code:
Imports ADAHSTableAdapters
<System.ComponentModel.DataObject()> _
Public Class CategoriesBLL
Private _categoriesAdapter As CategoriesTableAdapter = Nothing
Protected ReadOnly Property Adapter() As CategoriesTableAdapter
Get
If _categoriesAdapter Is Nothing Then
_categoriesAdapter = New CategoriesTableAdapter()
End If
Return _categoriesAdapter (error line)
End Get
End Property
<System.ComponentModel.DataObjectMethodAttribute(System.ComponentModel.DataObjectMethodType.Select,
True)> _
Public Function GetCategories() As ADAHS.CategoriesDataTable
Return Adapter.GetCategories()
End Function
<System.ComponentModel.DataObjectMethodAttribute(System.ComponentModel.DataObjectMethodType.Select,
False)> _
Public Function GetCategoryByCategoryID(ByVal categoryID As
Integer) As ADAHS.CategoriesDataTable
Return Adapter.GetCategoriesByCategoryID(categoryID)
End Function
End Class
Error Message on aspx page:
Failed to enable constraints. One or more rows contain values
violating non-null, unique, or foreign-key constraints.
Description: An unhandled exception occurred during the execution of
the current web request. Please review the stack trace for more
information about the error and where it originated in the code.
Exception Details: System.Data.ConstraintException: Failed to enable
constraints. One or more rows contain values violating non-null,
unique, or foreign-key constraints.
Source Error:
Line 2931: Me.Adapter.SelectCommand =
Me.CommandCollection(0)
Line 2932: Dim dataTable As ADAHS.CategoriesDataTable = New
ADAHS.CategoriesDataTable
Line 2933: Me.Adapter.Fill(dataTable)
Line 2934: Return dataTable
Line 2935: End Function
Stack Trace:
[ConstraintException: Failed to enable constraints. One or more rows
contain values violating non-null, unique, or foreign-key
constraints.]
.....More stuff,
CategoriesBLL.GetCategories() in C:\DNN_Web_Dev\ADAHS\App_Code\BLL
\CategoriesBLL.vb:18
Now when I preview the data in my tableadapter (categoriesDataTable) I
have no problem everything is displayed properly, but when I try and
link the Drop Down List to it I get the same error. I have tried not
using the BLL file and get the same error. Line 18 is "Return
_categoriesAdapter"
So where am I going wrong?
Thanks