Crystal Report: Failed to enable constraints. One or more rows contain values
Hi vbforums users!!
I have the following code:
Code:
Dim rpt As New rptInvoice() 'Crear nuevo reporte
Dim myConnection As MySqlConnection
Dim MyCommand As New MySqlCommand()
Dim myDA As New MySqlDataAdapter()
Dim myDS As New timetracking2DataSet 'Dataset a modificar
myConnection = New MySqlConnection("Data Source=xxxxx;Database=xxxxx;User ID=xxxx;Password=xxxxx;")
MyCommand.Connection = myConnection
'MyCommand.CommandText = "SELECT * FROM BillInfo INNER JOIN ProductSold ON BillInfo.InvoiceNo = ProductSold.InvoiceNo INNER JOIN Customer ON BillInfo.CustomerNo = Customer.CustomerNo WHERE billinfo.invoiceno= '" & frmSales.txtInvoiceNo.Text & "'"
MyCommand.CommandText = "SELECT * FROM BillInfo INNER JOIN ProductSold ON BillInfo.InvoiceNo = ProductSold.InvoiceNo INNER JOIN Customer ON BillInfo.CustomerNo = Customer.CustomerNo WHERE billinfo.invoiceno= '" & frmSales.txtInvoiceNo.Text & "'"
MyCommand.CommandType = CommandType.Text
myDA.SelectCommand = MyCommand
myDA.Fill(myDS, "BillInfo")
myDA.Fill(myDS, "productsold")
'myDA.Fill(myDS, "customer")
rpt.SetDataSource(myDS)
CrystalReportViewer1.ReportSource = rpt
CrystalReportViewer1.RefreshReport()
CrystalReportViewer1.Show()
in the field:
Code:
myDA.Fill(myDS, "productsold")
works great, but in the other 2 cases:
Code:
myDA.Fill(myDS, "BillInfo")
and
Code:
myDA.Fill(myDS, "customer")
say me that Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints.
My database in
Code:
myDA.Fill(myDS, "productsold")
wont have Primary Key, but in the other 2 cases I have a primary Key.. any idea to fix this? :(
I have VisualStudio 2010 + MySQL
Best Regards!!
Re: Crystal Report: Failed to enable constraints. One or more rows contain values
This has nothing to do with Crystal Reports. You should ask this question in VB .Net forum. That being said, the error message states what the problem is in general terms.
Quote:
One or more rows contain values violating non-null, unique, or foreign-key constraints.
You need to check you tables for any of those problems. Look at what relations are setup between those tables. Check if there are any records in the child table that don't have a foreign key match in the parent table.