I have a C# forms application that I am developing using MS Visual Studio 2005. I am trying to add some Crystal Reports to this application using the built in Crystal Reports tools with Visual Studio.
It seems like it should be pretty straight forward, but no matter what I do I can't get my reports to actually show data. Here's the info:
I created a crystal report viewer on a form. I created a crystal report that has a data source of a table in my database. Nothing fancy... just showing some of the fields from the table on the report. Whenever I use the preview button in the design of the report it fills it in with generic data (not pulling from my database).
I have the following code to load the report into the viewer:
Expand|Select|Wrap|Line Numbers
- TestReport rptTest = new TestReport();
- CrystalDecisions.Shared.ConnectionInfo crDbConnection = new
- CrystalDecisions.Shared.ConnectionInfo();
- crDbConnection.IntegratedSecurity = true;
- crDbConnection.DatabaseName = "accessgwc";
- crDbConnection.ServerName = "Access-server2";
- CrystalDecisions.CrystalReports.Engine.Database crDatabase =
- rptTest.Database;
- CrystalDecisions.Shared.TableLogOnInfo oCrTableLoginInfo;
- foreach (CrystalDecisions.CrystalReports.Engine.Table oCrTable in
- crDatabase.Tables)
- {
- oCrTableLoginInfo = oCrTable.LogOnInfo;
- oCrTableLoginInfo.ConnectionInfo = crDbConnection;
- oCrTable.ApplyLogOnInfo(oCrTableLoginInfo);
- }
- crystalReportViewer1.ReportSource = rptTest;
Does anyone know what I'm missing? Is there a way I can preview this report and see real data in it (prior to runtime)? I would really appreciate any help.
If you need more details just let me know.
Thanks,
Rod