Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# CrystalReports
Hi,
 
I am using two stored procedures, one for main report and another for subreport.Below is the code.
 

 
private void LoadSalesOrderReport()
            {
               
                string Type = gvQuotationDetails.Rows[QuoteIndex].Cells["Type"].EditedFormattedValue.ToString();
                FilePath = ConfigurationManager.AppSettings["EMP_IMG_PATH"].ToString() + "\\"" + ValQuoteID.ToString() + ".pdf";
                DeleteExistingFile(FilePath);
                try
                {
                    AccountsPayableMaster objAPM = new AccountsPayableMaster();
                    QuotationReport obj = new QuotationReport();
                    objReportDocument.Load(Application.StartupPath + @"\rptQuotationReport.rpt");
                    obj.crysQuotationReport.LogOnInfo = objAPM.ConnectionDetails("SD_SalesOrderReport;1");
                    obj.crysQuotationReport.LogOnInfo = objAPM.ConnectionDetails("SD_GetBatchReportDetails;1");
                    obj.crysQuotationReport.ReportSource = objReportDocument;
                    objReportDocument.SetParameterValue("@QuoteID", ValQuoteID);
                    objReportDocument.SetParameterValue("Type","-"+ Type.ToUpper()+"-");
                    objReportDocument.SetParameterValue("@QuoteID", ValQuoteID,objReportDocument.Subreports[0].Name.ToString());                
                    string[] Print = objAPM.GetPrintDetails();
                    SetPrintParameters(objReportDocument, Print);
                    obj.Show();
                    objReportDocument.ExportToDisk(ExportFormatType.PortableDocFormat, FilePath);
    
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
    
                }
               
                OpenPdfFile();
            }
 

 
 

private void OpenPdfFile()
        {
            try
            {
 
                Process.Start(FilePath);
            }
            catch (Exception ex)
            {
 
                MessageBox.Show("Please install MicrosoftOffice/Pdf Reader to view files", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
 
            }
           
 
    }

 
The code is working fine.But the problem is. when i click the button in front end to show the pdf directly.The crystal report form is also displayed and I know the reason as I am using **obj.Show** in my code.I tried to comment it but it throws an error.Can any one advise changes in my code to directly display the pdf and not the crystalreport form.
Posted 25-Feb-13 8:06am
Edited 25-Feb-13 8:10am
v2
Comments
Sandeep Mewara at 25-Feb-13 13:33pm
   
What error? Always add the details of the issue you face to get quick response that helps.
Prathap Gangireddy at 26-Feb-13 23:22pm
   
Hi Sandeep, When I am commenting out obj.show(). It gives an error like incorrect logon parameters and when i uncomment it works fine.

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Prathap Gangireddy wrote:
Hi Sandeep, When I am commenting out obj.show(). It gives an error like incorrect logon parameters and when i uncomment it works fine.

You have to apply logon details to reports run time dynamically.
C# Crystal Reports Dynamic Logon parameters[^]
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 5,130
1 DamithSL 4,237
2 Maciej Los 3,700
3 Kornfeld Eliyahu Peter 3,470
4 Sergey Alexandrovich Kryukov 2,846


Advertise | Privacy | Mobile
Web04 | 2.8.141216.1 | Last Updated 31 Oct 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100