title: How to set datasource of sub report in crystal report for master detail table
body: <p><img src="https://i.stack.imgur.com/dvCDf.png" alt="enter image description here"></p>
  
  <p>I've these two tables, I want to generate a crystal report in which I've a sub report listing all the orders by store. But I'm having problem setting data source of sub report. </p>
  
  <pre><code>ReportsDataSetTableAdapters.StoreTableAdapter adp = new ReportsDataSetTableAdapters.StoreTableAdapter();
  MainOrderReport report = new MainOrderReport();
  ReportsDataSetTableAdapters.OrderTableAdapter del = new ReportsDataSetTableAdapters.OrderTableAdapter();
  report.Subreports[0].SetDataSource(del.GetData().DefaultView);
  report.SetDataSource(adp.GetData().DefaultView);
  crystalReportViewer.ReportSource = report;
  crystalReportViewer.Refresh();
  </code></pre>
  
  <p>But this code is throwing this exception:
  "Failed to enable constraints. One or more rows contain values violating non-null, unique or foreign-key constraints". 
  Kindly help me, what I'm missing here.</p>