Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Failed to enable constraints. One or more rows contain value
Message
De
06/12/2007 10:51:12
 
 
À
Tous
Information générale
Forum:
ASP.NET
Catégorie:
The Mere Mortals .NET Framework
Titre:
Failed to enable constraints. One or more rows contain value
Divers
Thread ID:
01273622
Message ID:
01273622
Vues:
74
Hi Kevin,

I have two business objects with a parent child relationship which binds to two different mmgridview, but somehow I get the following message

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

Here is what I have for the Child Bussiness object
Partial Public Class OSPOrderRefundDetail
    Inherits ABusinessObject(Of OSPOrderRefundDetailEntity)


#Region "Association Properties"

    '''<summary>
    ''' Business Entity object
    ''' </summary>
    Public Overrides Property Entity() As OSPOrderRefundDetailEntity
        Get
            If Me._entity Is Nothing Then
                Me._entity = Me.CreateEntityObject()
            End If
            Me._entity.SetDataRow(Me.DataRow)
            Return Me._entity
        End Get
        Set(ByVal value As OSPOrderRefundDetailEntity)
            Me._entity = value
        End Set
    End Property
    Private _entity As OSPOrderRefundDetailEntity

#End Region

    ''' <summary>
    ''' Constructor
    ''' </summary>
    Public Sub New()
        Me.TableName = "OSP_OrderDetail_S"
        Me.PrimaryKeys = New String() {"OrderNumber", "LineItemBvin"}
        Me.DefaultCommandType = CommandType.StoredProcedure
        Me.DatabaseKey = "FRONTOFFICE"
        Me.ForeignParentKeyField = "OrderNumber"
       
    End Sub

    ''' <summary>
    ''' Returns all Order Detail for the specified order ID
    ''' </summary>
    ''' <param name="orderID">Order ID</param>
    ''' <returns>DataTable containing order detail</returns>
    Public Function GetOrderDetail(ByVal orderID As String) As mmBindingList(Of OSPOrderRefundDetailEntity)

        Dim OrderDetailList As mmBindingList(Of OSPOrderRefundDetailEntity)

        If Not String.IsNullOrEmpty(orderID) Then
            OrderDetailList = Me.GetEntityList("OSP_OrderDetail_S", _
                Me.CreateParameter("@OrderNumber", CInt(orderID)))
        Else
            'Me.GetEmptyDataSet()
            OrderDetailList = New mmBindingList(Of OSPOrderRefundDetailEntity)()
            OrderDetailList = Me.GetEntityList("OSP_OrderDetail_S", _
              Me.CreateParameter("@OrderNumber", CInt("-1")))
        End If
        Return OrderDetailList
    End Function

    ''' <summary>
    ''' Parent Retrieved hook method
    ''' </summary>
    ''' <param name="bizObj">Parent business object</param>
    ''' <param name="e">EventArgs</param>
    Protected Overrides Sub HookParentRetrieved(ByVal bizObj As mmBusinessObject, ByVal e As mmBusinessStateChangeEventArgs)
        Me.GetOrderDetail(CType(e.PrimaryKeyValue, String))
    End Sub

    ''' <summary>
    ''' Parent Navigated hook method
    ''' </summary>
    ''' <param name="bizObj">Parent business object</param>
    ''' <param name="e">EventArgs</param>
    Protected Overrides Sub HookParentNavigated(ByVal bizObj As mmBusinessObject, ByVal e As mmBusinessStateChangeEventArgs)
        Me.GetOrderDetail(CType(e.PrimaryKeyValue, String))
    End Sub

below is the data retrieved when I manually run the stored procedure
20238	B1051-1	B1051-1	00f3caa2-2684-4f75-bd73-fef63e13bf94	100.0000000000	ykhan@acelosolutions.com	Khan,Yassin	ykhan                                                         	Khan,Yassin	0	Enter comments
20238	B1051-9	TEST	b034cc22-5ebd-4b00-b144-b44a4bced325	1.0000000000	ykhan@acelosolutions.com	Khan,Yassin	acelo                                                         	Solutions,Acelo	0	Enter comments
20238	B1051-10	TEST-19191	3ec57ed4-6d37-4561-8a56-74b059bc6963	10.0000000000	ykhan1@acelosolutions.com	Acelo,Khan	ykhan                                                         	Khan,Yassin	0	Enter comments
when the child transactions are retrieved. I only get that message on few transactions.

The child and parent business object where created using stored procedures.
Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints.

at System.Data.DataSet.FailedEnableConstraints()
   at System.Data.DataSet.EnableConstraints()
   at System.Data.DataSet.set_EnforceConstraints(Boolean value)
   at System.Data.DataTable.EndLoadData()
   at System.Data.Common.DataAdapter.FillFromReader(DataSet dataset, DataTable datatable, String srcTable, DataReaderContainer dataReader, Int32 startRecord, Int32 maxRecords, DataColumn parentChapterColumn, Object parentChapterValue)
   at System.Data.Common.DataAdapter.Fill(DataSet dataSet, String srcTable, IDataReader dataReader, Int32 startRecord, Int32 maxRecords)
   at System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
   at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
   at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String srcTable)
   at OakLeaf.MM.Main.Data.mmDataAccessSql.FillDataSet(DataSet ds, IDbDataAdapter dbAdapter, String tableName, Boolean clearOnFill)
   at OakLeaf.MM.Main.Data.mmDataAccessSql.FillDataSet(DataSet ds, IDbCommand command, String tableName, Boolean clearOnFill)
   at OakLeaf.MM.Main.Data.mmDataAccessSql.FillDataSet(DataSet ds, String command, String tableName, CommandType cmdType, IDbDataParameter[] dataParms, Boolean clearOnFill)
   at OakLeaf.MM.Main.Business.mmBusinessObject.FillDataSet(DataSet ds, String command, String tableName, String databaseKey, CommandType cmdType, IDbDataParameter[] dataParams)
   at OakLeaf.MM.Main.Business.mmBusinessObjectGeneric`1.GetEntityList(String command, String databaseKey, CommandType cmdType, IDbDataParameter[] dataParams)
   at OakLeaf.MM.Main.Business.mmBusinessObjectGeneric`1.GetEntityList(String command, String databaseKey, IDbDataParameter[] dataParams)
   at OakLeaf.MM.Main.Business.mmBusinessObjectGeneric`1.GetEntityList(String command, IDbDataParameter[] dataParams)
   at ACELO.OSP.BUSINESS.OSPOrderRefundDetail.GetOrderDetail(String orderID) in C:\OSP_11052007\Acelo.OSP.Business\Acelo.OSP.Business\OSPOrderRefundDetail.vb:line 65
   at ACELO.OSP.BUSINESS.OSPOrderRefundDetail.HookParentRetrieved(mmBusinessObject bizObj, mmBusinessStateChangeEventArgs e) in C:\OSP_11052007\Acelo.OSP.Business\Acelo.OSP.Business\OSPOrderRefundDetail.vb:line 82
   at OakLeaf.MM.Main.Business.mmBusinessObject.StateChangeHandler(mmBaseBusinessObject bizObj, mmBusinessStateChangeEventArgs e)
   at OakLeaf.MM.Main.Business.mmBusinessStateChangeDelegate.Invoke(mmBaseBusinessObject bizObj, mmBusinessStateChangeEventArgs e)
   at OakLeaf.MM.Main.Business.mmBusinessObject.OnStateChange(mmBusinessState bizState, String tableName, Object primaryKeyValue, Object[] primaryKeyValues)
   at OakLeaf.MM.Main.Business.mmBusinessObject.CallStateChange(mmBusinessState bizState, String tableName, DataRow dr)
   at OakLeaf.MM.Main.Business.mmBusinessObject.CallStateChange(mmBusinessState bizState, String tableName)
   at OakLeaf.MM.Main.Business.mmBusinessObject.FillDataSet(DataSet ds, String command, String tableName, String databaseKey, CommandType cmdType, IDbDataParameter[] dataParams)
   at OakLeaf.MM.Main.Business.mmBusinessObjectGeneric`1.GetEntityList(String command, String databaseKey, CommandType cmdType, IDbDataParameter[] dataParams)
   at OakLeaf.MM.Main.Business.mmBusinessObjectGeneric`1.GetEntityList(String command, String databaseKey, IDbDataParameter[] dataParams)
   at OakLeaf.MM.Main.Business.mmBusinessObjectGeneric`1.GetEntityList(String command, IDbDataParameter[] dataParams)
   at ACELO.OSP.BUSINESS.OSPRefundOrder.GetOrdersByPurchaserName(String PurchaserName, String INTERID, Int32 ALL) in C:\OSP_11052007\Acelo.OSP.Business\Acelo.OSP.Business\OSPRefundOrder.vb:line 55
   at ACELO.OSP.WINDOW.MainOnlineActivityForm.FindRefundOrders() in C:\OSP_11052007\Acelo.OSP.Window\Acelo.OSP.Window\MainOnlineActivityForm.vb:line 1120
   at ACELO.OSP.WINDOW.MainOnlineActivityForm.txtRefund_TextChanged(Object sender, EventArgs e) in C:\OSP_11052007\Acelo.OSP.Window\Acelo.OSP.Window\MainOnlineActivityForm.vb:line 1099
   at System.Windows.Forms.Control.OnTextChanged(EventArgs e)
   at System.Windows.Forms.TextBoxBase.OnTextChanged(EventArgs e)
   at System.Windows.Forms.TextBoxBase.WmReflectCommand(Message& m)
   at System.Windows.Forms.TextBoxBase.WndProc(Message& m)
   at System.Windows.Forms.TextBox.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
   at System.Windows.Forms.UnsafeNativeMethods.SendMessage(HandleRef hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
   at System.Windows.Forms.Control.SendMessage(Int32 msg, IntPtr wparam, IntPtr lparam)
   at System.Windows.Forms.Control.ReflectMessageInternal(IntPtr hWnd, Message& m)
   at System.Windows.Forms.Control.WmCommand(Message& m)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
   at System.Windows.Forms.UnsafeNativeMethods.CallWindowProc(IntPtr wndProc, IntPtr hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
   at System.Windows.Forms.NativeWindow.DefWndProc(Message& m)
   at System.Windows.Forms.Control.DefWndProc(Message& m)
   at System.Windows.Forms.Control.WmKeyChar(Message& m)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.TextBoxBase.WndProc(Message& m)
   at System.Windows.Forms.TextBox.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
   at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
   at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
   at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
   at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
   at System.Windows.Forms.Application.Run(Form mainForm)
   at ACELO.OSP.WINDOW.AppMainEntry.Main() in C:\OSP_11052007\Acelo.OSP.Window\Acelo.OSP.Window\Main.vb:line 65
Your assistance will be appreciated.

Thanks
Yassin
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform