pi***********@psitek.com (Pierre) wrote in message news:<db*************************@posting.google.c om>...
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();
-----------------------