Click here to Skip to main content
15,906,333 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi,

I have written a code to open a report in the crystal viewer and it is working fine in Windowsxp machine however when i try and run it in the WIndows 7 machine i am getting a blank report. Below is the code i am using.

Could you please let me know what i am doing wrong here due to which the report is being displayed as blank.

C#
frmReportViewer = frmRptViewer.CreateInstance();
frmReportViewer.crystlRpt = null;


//Provider Letter
frmReportViewer.crystlRpt = MemoryHelper.ReleaseAndCleanObject<CRAXDDRT.Report>(frmReportViewer.crystlRpt, (CRAXDDRT.Report)crystlApp.OpenReport(modAUTHFE.gstrReportRootDir + "\\CLAIMS\\test123.rpt", Type.Missing));

frmReportViewer.crystlRpt.Database.LogOnServer("pdsodbc.dll", "DB", "Claims", modAUTHFE.gstrUID, modAUTHFE.gstrPWD);

frmReportViewer.crystlRpt.EnableParameterPrompting = false;
frmReportViewer.crystlRpt.ParameterFields[1].AddCurrentValue(DateTime.Parse(strBeginLetterDate));
frmReportViewer.crystlRpt.ParameterFields[2].AddCurrentValue(DateTime.Parse(strEndLetterDate));

//frmReportViewer = frmRptViewer.CreateInstance();
frmReportViewer.CRViewer.ReportSource = frmReportViewer.crystlRpt;
frmReportViewer.CRViewer.ViewReport();
frmReportViewer.CRViewer.EnableExportButton = true;
frmReportViewer.Top = (int)0;
frmReportViewer.Left = (int)0;

frmReportViewer.ShowDialog();
Posted

I am not understand your code, but i know how we display data in crystal report by small code.

here are sample.

First step. u need to create a new file of dataset (.xsd), give it name like dataset1.
In this dataset u make the all colum which u want to display.

2nd step: add a new crystal report file give it name crystalreport1
in field Explorer->datbasefiled->databaseexpert->projectdata->ado.net dataset

then select dataset1, which u maked in 1st step. drag drop ur colum from fileexploer to crystal report.

3rd step: in a form u add crystalreportviwer suppose it's name is crystalreportvier1

write the below code on formload event of form on which u take crystalreportview1

SqlConnection con = new SqlConnection("connection string");
     string query = "Your query";
     SqlDataAdapter da = new SqlDataAdapter(query, con);
     DataSet1 ds1 = new DataSet1();
     da.Fill(ds1.Tables.Add("Items")); //item is just table name in dataset
     CrystalReport1 objRpt = new CrystalReport1();
     objRpt.SetDataSource(ds1.Tables["Items"]);
     crystalReportViewer1.ReportSource = objRpt;
     crystalReportViewer1.Refresh();
 
Share this answer
 
v2
Hey
try telerik reporting , its so better than crystal report !
 
Share this answer
 
Comments
anupama962010 22-Jun-13 1:54am    
We have to use the crystal reports only

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900