How do I populate Crystal Reports, using a DataTable?

  • Thread starter Thread starter Pierre
  • Start date Start date
P

Pierre

Hi,

Can anyone tell me how I can populate Crystal Reports, using a DataTable in C#?

Regards,
Pierre
 
Hi,

Can anyone tell me how I can populate Crystal Reports, using a DataTable in C#?

Regards,
Pierre

Pierre,

This is how you do it using OLEDB, and a table view in MSSQL. This assumes
you have setup your report viewer with the wizard.

-------------------------

dataSet21.Clear();
oleDbDataAdapter1.Fill(dataSet21,"your_table_view");

CrystalReport2 custReport = new CrystalReport2();
custReport.SetDataSource(dataSet21);

TableLogOnInfo logOnInfo = new TableLogOnInfo();
logOnInfo = custReport.Database.Tables["your_table_view"].LogOnInfo;
ConnectionInfo connectionInfo = new ConnectionInfo ();
connectionInfo = logOnInfo.ConnectionInfo;
// Set the Connection parameters.
connectionInfo.DatabaseName = yourcatalog;
connectionInfo.ServerName = workstationID;
MessageBox.Show(connectionInfo.ServerName);
//connectionInfo.Password = "yourpassword";
//connectionInfo.UserID = "youruserid";
custReport.Database.Tables ["Vw_Address_Label"].ApplyLogOnInfo(logOnInfo);
crystalReportViewer1.ReportSource = custReport;
crystalReportViewer1.Refresh();
crystalReportViewer1.RefreshReport();
-----------------------
 
Hi Brent,

Thanks, but I am still have major difficulty getting Crystal Reports to
work properly.

I have three tiers i.e. ASP.Net, Business Logic Layer and the Data
Access Layer. I get the data back from an stored proc on a SQL 2000
database and then manipulate the DataTable in the Business Logic layer,
filtering out certain records, in order to obtain the data which needs
to be displayed on the report.

The problem I am having, is populating the unbound "fields" on the
actual report with data. The report is being displayed, but I cannot
find documentation on populating the actual fields.

Does anyone PLEASE know of a way in which I can do this?

Thanks,
Pierre
 
Back
Top