pi***********@p sitek.com (Pierre) wrote in message news:<db******* *************** ***@posting.goo gle.com>...
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 ();
oleDbDataAdapte r1.Fill(dataSet 21,"your_table_ view");
CrystalReport2 custReport = new CrystalReport2( );
custReport.SetD ataSource(dataS et21);
TableLogOnInfo logOnInfo = new TableLogOnInfo( );
logOnInfo = custReport.Data base.Tables["your_table_vie w"].LogOnInfo;
ConnectionInfo connectionInfo = new ConnectionInfo ();
connectionInfo = logOnInfo.Conne ctionInfo;
// Set the Connection parameters.
connectionInfo. DatabaseName = yourcatalog;
connectionInfo. ServerName = workstationID;
MessageBox.Show (connectionInfo .ServerName);
//connectionInfo. Password = "yourpasswo rd";
//connectionInfo. UserID = "youruserid ";
custReport.Data base.Tables ["Vw_Address_Lab el"].ApplyLogOnInfo (logOnInfo);
crystalReportVi ewer1.ReportSou rce = custReport;
crystalReportVi ewer1.Refresh() ;
crystalReportVi ewer1.RefreshRe port();
-----------------------