p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   Crystal Reports (http://p2p.wrox.com/forumdisplay.php?f=113)
-   -   I want to view a report on Webform ASP.NET/ (http://p2p.wrox.com/showthread.php?t=1414)

kid1981 July 9th, 2003 04:14 AM

I want to view a report on Webform ASP.NET/
 
I have a report creat with crytal report/
I want to view it on Webform ASP.NET/
Help me now//
Thanks/



melvik July 10th, 2003 01:09 AM

I hope this can help.
http://msdn.microsoft.com/library/de...talreports.asp

Always:),
Hovik Melkomian.

kid1981 July 10th, 2003 06:21 PM

Yes, I have already done it/
But I don't known export report to File from page N to page M/
Do you help me/
"Export to File or Export to Plug-in msword" from page to page/
Thanks


debsoft July 16th, 2003 02:20 AM

Hi Kid1981,


It's easy...First u create a Dataset and populate the dataset using a Stored Proc or any other sources and then base your report on this dataset...Then once the report is displayed in CRViewer , u can export it on the click of a print button using the code I mention below. This code exports to PDF...u can export it to any other format. Just go thru the code properly and u will understand what to do...

using CrystalDecisions.CrystalReports.Engine ;
using CrystalDecisions.Shared ;

try
            {
                string Fname;
                bool lboolExists = false ;

                ExportOptions crExportOptions = new ExportOptions();

                // populating dataset and binding to report
                dsCampSumm = PopulateDataSet();

                // binding report again
                                //CampSumm is the reportname
                oRptCampSumm = new CampSumm();
                oRptCampSumm.SetDataSource(dsCampSumm);

                //This section of code is needed to check for existence of the folder
                //where the pdf file will be temporarily stored
                //--------------------------------------------------------------------------
                Scripting.FileSystemObject lObjFSO ;
                lObjFSO = new Scripting.FileSystemObjectClass();

                lboolExists = lObjFSO.FolderExists(Server.MapPath("../../SaleSourceTemplates/" + GetSessionAgencyId()));
                // Check for the folder name equal to Agency_id if false create one
                if (lboolExists == false)
                {
                    lObjFSO.CreateFolder(Server.MapPath("../../SaleSourceTemplates/" + GetSessionAgencyId()));
                }
                //--------------------------------------------------------------------------

                Fname = Server.MapPath("../../SaleSourceTemplates/" + GetSessionAgencyId() + "/") + Session.SessionID.ToString() + ".pdf";
                DiskFileDestinationOptions CrDiskFileDestinationOptions = new DiskFileDestinationOptions();
                CrDiskFileDestinationOptions.DiskFileName = Fname;
                crExportOptions = oRptCampSumm.ExportOptions;
                crExportOptions.DestinationOptions = CrDiskFileDestinationOptions;
                crExportOptions.ExportDestinationType = ExportDestinationType.DiskFile;
                crExportOptions.ExportFormatType = ExportFormatType.PortableDocFormat;
                oRptCampSumm.Export();

                // The following code writes the pdf file to the Client’s browser.
                Response.ClearContent();
                Response.ClearHeaders();
                Response.ContentType = "application/pdf";
                Response.WriteFile(Fname);
                Response.Flush();
                Response.Close();
                //delete the exported file from disk
                System.IO.File.Delete(Fname);
            }
            catch(Exception ex)
            {
                throw new Exception(ex.Message);
            }



private DsReport PopulateDataSet()
        {
            dsCampSumm = new DsReport();

            try
            {
                gstrQuery="sp_CampSumm ";

                if (Request.QueryString["CampId"]=="All") //CampId
                    gstrQuery=gstrQuery + BusinessRules.Reports.CAMPID + ",";
                else
                    gstrQuery=gstrQuery + Request.QueryString["CampId"] + ",";

                if (Request.QueryString["CampManagerId"]=="All") //CampManagerId
                    gstrQuery=gstrQuery + BusinessRules.Reports.MANAGERID + ",";
                else
                    gstrQuery=gstrQuery + Request.QueryString["CampManagerId"] + ",";

                if (Request.QueryString["StartDate"]!=null) //Start Date
                    gstrQuery=gstrQuery + "'" + Request.QueryString["StartDate"] + "'" + ",";
                else
                    gstrQuery=gstrQuery + "''" + ",";

                if (Request.QueryString["Status"]!=null) //Status
                    gstrQuery=gstrQuery + "'" + Request.QueryString["Status"] + "'" + ",";
                else
                    gstrQuery=gstrQuery + "'" + BusinessRules.Reports.STATUSBOTH + "'" + ",";

                if (Request.QueryString["Launch"]!=null) //Launched
                    gstrQuery=gstrQuery + "'" + Request.QueryString["Launch"] + "'" + ",";
                else
                    gstrQuery=gstrQuery + "'" + BusinessRules.Reports.LAUNCHBOTH + "'" + ",";

                gstrQuery=gstrQuery + GetSessionAgencyId() + ",";
                gstrQuery=gstrQuery + GetSessionBranchId();

                SqlConnection myconnection = new SqlConnection() ;
                //myconnection.ConnectionString = "server=DEBARSHI;database=SaleSource;uid=SSAdmin;p wd=admin";
                myconnection.ConnectionString = "Server=" + GetDatabaseServerName() + ";" +
                    "Database=" + GetDatabaseName() + ";" +
                    "uid=" + GetSQLUserId() + ";" +
                    "pwd=" + GetSQLPassword();
                myconnection.Open();

                SqlCommand mycommand = new SqlCommand();
                mycommand.Connection = myconnection;
                mycommand.CommandText = gstrQuery;
                mycommand.CommandType = CommandType.Text;

                SqlDataAdapter da = new SqlDataAdapter();
                da.SelectCommand = mycommand;
                da.Fill(dsCampSumm, "CampaignSummary");
            }
            catch(Exception pEx)
            {
                throw new SaleSourceException(pEx.Message + " " + pEx.StackTrace,pEx,GetSessionUserId());
            }
            return dsCampSumm;
        }
Quote:

quote:Originally posted by kid1981
 Yes, I have already done it/
But I don't known export report to File from page N to page M/
Do you help me/
"Export to File or Export to Plug-in msword" from page to page/
Thanks


cheers,
debsoft

kid1981 July 26th, 2003 04:19 AM

Thanks all friend/
Now, I want to push parameter from "ASP.NET Form" to a report/
But I don't known it/
do you help me???
Thanks


melvik July 26th, 2003 04:43 AM

Hi there:
I hope this sample will help u to pass parameter to Report File.
(Use '@' if u use Stored Procedure in ur report)

  reports.vekalat crReportDocument;
  ParameterFields crParameterFields;
  ParameterField crParameterField;
  ParameterValues crParameterValues;
  ParameterDiscreteValue crParameterDiscreteValue;

  private void Page_Load(object sender, System.EventArgs e)
  {
  crReportDocument = new REPORT_NAME();

  CrystalReportViewer1.ReportSource = crReportDocument;
  crParameterFields = CrystalReportViewer1.ParameterFieldInfo;
  crParameterField = crParameterFields["@PARAMETER_NAME"];
  crParameterValues = crParameterField.CurrentValues;

  crParameterDiscreteValue = new ParameterDiscreteValue();
  crParameterDiscreteValue.Value = PARAMETER_VALUE;
  crParameterValues.Add(crParameterDiscreteValue);
  }

let me know about that.


Always:),
Hovik Melkomian.

kid1981 July 26th, 2003 04:53 AM

example:
I have a InputBox + a Button
and CrystalView --> view a Report/
I want to tranfer a Parameter from InputBox before "Button" Click
Do you help me???
Thanks all


melvik July 26th, 2003 05:09 AM

I tryed to be clear in my sample so if u want to set a parameter value :
Code:

crParameterDiscreteValue.Value = PARAMETER_VALUE;
do it like follow:
Code:

crParameterDiscreteValue.Value = textBox.Text;
let me know if u get it.

Always:),
Hovik Melkomian.

kid1981 July 27th, 2003 09:57 PM

I don't known C#, may be you send code VB.NET for me???


melvik July 27th, 2003 10:35 PM

I dont know VB:D next time mention ur lang for forum.

Always, Hovik.


All times are GMT -4. The time now is 08:07 PM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.