cseay

cseay

  • NA
  • 1
  • 0

Populating a Crystal Report by a dataset

Dec 10 2004 2:14 PM
Hi all: I have a MS Access database which has a query called “Inv_History” which I want to deliver its contents onto a Crystal Report via a Crystal Report Viewer in a Windows Form. I did the following: 1) Created a dataset called InvHist_xsd using the drag/drop from the Server Explorer>>Data Connections>>ACCESS (current data connection)>>Views. 2) Saved this and did a Build>>Build Solution to create the object. 3) Did Add>>Add New Item>>new CrystalReport. Used the Report Export. · In the Data Tab, I selected Project Data>>ADO.NET DataSets>>InvHist_xsd and found the table in this. Double clicked to select. · Selected all columns and clicked Finish. 4) In a new Windows Form I clicked and dragged a datagrid and a Crystal Report Viewer into the form. 5) I put in the following code in the form load event: InvHist_xsd History_report_datasetxsd = new InvHist_xsd(); string sql_SELECT = "Select cat_name, inv_id,invdet_date,m_type,invdet_total from Inv_history"; // System.Data.OleDb.OleDbConnection conn = new System.Data.OleDb.OleDbConnection(Globals.sConnString); System.Data.OleDb.OleDbDataAdapter OleDbDataAdapter1 = new System.Data.OleDb.OleDbDataAdapter(sql_SELECT,conn); OleDbDataAdapter1.Fill(History_report_datasetxsd,"History"); this.dataGrid1.SetDataBinding(History_report_datasetxsd,"History"); CrystalReport1 report1 = new CrystalReport1(); report1.SetDataSource(History_report_datasetxsd); this.crystalReportViewer1.ReportSource = report1; The Datagrid populates, the Report in the viewer populates header information but no data. I have tried a similar workup using the ReportDocument component with similar success. Does anybody have an idea on what I’m not doing right? Thanks in advance.