Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p><strong>Good evening all,</strong></p> <p>So after hours of reading and searching the web, I've managed to arrive at or better yet, discover, a solution to my problem.</p> <p>It appears that even though I'd created a DataSet within VS and used that to create my CR Report, I wasn't actually using that DataSet in code. Instead what I was doing was creating a new DataTable at run-time, filling that with my query result, and setting the report's datasource property to it.</p> <p>What I should have been doing was to create an instance of my DataSet (the one I created earlier and used to design the report), fill it with my query result, and set the report's datasource property to it. This allowed CR to recognize and respect the table links/relationships I established earlier in the DataSet designer. I also learned that when using the DataAdapter with a query that returns multiple tables, the default naming convention is "Table" then "Table1" and so forth - that it was necessary to map these to the actual names of my tables in the DB.</p> <p><strong>So after applying all these lessons, I had to re-do my code as follows:</strong></p> <pre><code> Dim report As New rptCardListAll Dim myConnectionString As String = "Server=" &amp; FormLogin.ComboBoxServerIP.SelectedItem &amp; ";Port=3306;Uid=parts;Password=parts;Database=accounting;" Dim dbConn As New MySqlConnection(myConnectionString) Dim dbQuery As String = "SELECT * FROM cc_master; " &amp; _ "SELECT * FROM customer;" Dim dbAdapter As New MySqlDataAdapter(dbQuery, dbConn) With dbAdapter .TableMappings.Add("Table", "cc_master") .TableMappings.Add("Table1", "customer") End With Try Dim dbDataSet As New accountingDataSet dbAdapter.Fill(dbDataSet) report.SetDataSource(dbDataSet) CrystalReportViewer1.ReportSource = report CrystalReportViewer1.Zoom(1) Catch ex As Exception MsgBox(ex.Message, MsgBoxStyle.OkOnly, "An Error Has Occured....") End Try </code></pre> <p>My report now shows the missing field "nameCOMPANY" from the customer table.</p> <p><strong>CREDIT:</strong> I want to thank @halfer, @luchosrock, and @EvilBob22 for their assistance. Also, I give credit to the authors in the following documents:</p> <p><a href="http://developer-content.emc.com/developer/downloads/CrystalReport_ADO_Dataset.pdf" rel="nofollow noreferrer">http://developer-content.emc.com/developer/downloads/CrystalReport_ADO_Dataset.pdf</a></p> <p><a href="https://stackoverflow.com/questions/11345761/how-to-fill-dataset-with-multiple-tables">How to fill Dataset with multiple tables?</a></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload