chokka
asked on
Failed to enable Constraints - Dataset
Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints.
This Method executes well for few Copay Id's and throwing exception for few copayid's.
I am confused, I am sure that, i need to implement Dataset.EnforceConstraint = False - But i really dont know .. where to implement ..!
This Method executes well for few Copay Id's and throwing exception for few copayid's.
I am confused, I am sure that, i need to implement Dataset.EnforceConstraint = False - But i really dont know .. where to implement ..!
Public Function GetCoPayToPrint(ByVal CoPayid As Integer) As MedISDataSet.copayreportDataTable
Dim CoPayPrint As MedISDataSet.copayreportDataTable
Try
CoPayPrint = New MedISDataSet.copayreportDataTable
CoPayPrint.AppRecDateColumn.DateTimeMode = DataSetDateTime.Utc
CoPayPrint.DOBColumn.DateTimeMode = DataSetDateTime.Utc
CoPayPrint.LFDColumn.DateTimeMode = DataSetDateTime.Utc
Dim cmd As New SqlCommand("GetCoPayToPrint", sqlConn)
cmd.CommandType = CommandType.StoredProcedure
cmd.Parameters.AddWithValue("@CoPayid", CoPayid)
Dim da As New SqlDataAdapter(cmd)
da.Fill(CoPayPrint)
Catch sqlex As Exception
EventLogHelper.LogFailureAudit(String.Format("The error was encountered while selecting LFD Data: " & ControlChars.NewLine & "{0}", sqlex.ToString()))
Throw New SoapException(sqlex.Message, SoapException.ServerFaultCode, "Database")
Finally
sqlConn.Close()
End Try
Return CoPayPrint
End Function
ASKER
ASKER
here is another issue -
Partial Public Class MedISDataSet
Inherits Global.System.Data.DataSet
MedISDataset is not a dataset. This is a class which is Inherited from System.Data.Dataset
I am not able to get MedISDataSet.EnforceConstr
Does it always work the very first time it runs?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Following code invokes the above the Method ..!
And i am getting another exception from this code.
Also, Dataset is used to load the Crystal Report .
Report file is expecting Dataset - Username / Password.
Public Shared Function GetCoPayToPrint(ByVal CoPayID As Integer) As MedISDataSet.copayreportDataTable
' SyncLock GetType(MedISServices)
Dim dataService As MedISServices = GetWebServiceReference()
Dim dataTable As MedISDataSet.copayreportDataTable = Nothing
Try
dataTable = dataService.GetCoPayToPrint(CoPayID)
Catch webEx As WebException
HandleWebServicesException(WebServicesExceptionType.WebException, webEx)
Catch soapEx As SoapException
If soapEx.Actor = "Security" Then
HandleWebServicesException(WebServicesExceptionType.SoapException, soapEx)
Else
HandleWebServicesException(WebServicesExceptionType.WebException, soapEx)
End If
Catch ex As Exception
HandleWebServicesException(WebServicesExceptionType.Exception, ex)
End Try
Return dataTable
'End SyncLock
End Function
Dataset-UserName-Password.JPGXMLError.JPG
ASKER
Is there anyway for us to disable or set enforce constraint = false in DataTable.
Since Parent datatable has key
ASKER
Thanks
Try
MedISDataSet.EnforceConstr
CoPayPrint = New MedISDataSet.copayreportDa
You don't care to find out what is wrong with the data?