H.Al H.Al - 1 year ago 114
Vb.net Question

Create crystal report in webservice method

OK so I have a SOAP web service that is used by a mobile application, I want to add a new webmethod that creates a report through crystal report and save it in a folder. I don't want to use reports published as webservices, I want my report to be created directly from my webmethod. So how it could be? NB: I am using visual studio 2010 and vb.net language.

Answer Source

You would need to download the CR_For_VS package and then use the ReportDocument class to export this to the folder

Edit: Code

You would need to reference the Crystal Libraries in your project to use the ReportDocument Class. The code below should give you a start.

  ReportDocument rep = new ReportDocument();

        rep.SetDatabaseLogon(Global.SQLUsername, Global.SQLPassword, Global.SQLServer, Global.SQLDatabase);

        foreach (ReportDocument subRep in rep.Subreports)
            subRep.SetDatabaseLogon(Global.SQLUsername, Global.SQLPassword, Global.SQLServer, Global.SQLDatabase);

        rep.SetParameterValue("QuoteID", SessionStore.Current.CurrentQuoteID);
        rep.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, SessionStore.Current.DownloadPath + "/" + gvrParent.Cells[(int)gvQuotesColumnIndex.QuoteNo].Text + ".pdf");
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download