Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > Crystal Reports
|
Crystal Reports General discussion about Crystal Reports. For discussions specific to the book Professional Crystal Reports for VS.NET, please see the book discussion forum for that book.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Crystal Reports section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 12th, 2003, 05:59 AM
Registered User
 
Join Date: Nov 2003
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default Pass Crystal parameter to a SQL sp

I would like to pass parameters to an SP. I already have created the SP and it has parameters, so now i need to know how point to it as the data source in Crystal.
If you also know where i can find samples, would wellcome.

Regards

cphspain

 
Old November 12th, 2003, 06:06 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 996
Thanks: 2
Thanked 11 Times in 11 Posts
Send a message via Yahoo to melvik
Default

Insure u can find many samples at http://www.crystaldecisions.com/prod...alreports/net/ but wait a min, have create ur Report (i mean .rpt file) or u just neet to set parameters from aspx files?


Always:),
Hovik Melkomian.
 
Old November 12th, 2003, 06:42 AM
Registered User
 
Join Date: Nov 2003
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Well, i have some sp that update tables and others are just only querys that not need special kind of report.
For the first one, sp that update tables, the idea is put a link on intranet, that after click oon it, open a crystal report where the first step is ask to the user for Start & End dates, these are the parameters that i need to pass to the SP.
After entered the dates sp run and refresh the report.

Thank you

cphspain

 
Old November 12th, 2003, 07:01 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 996
Thanks: 2
Thanked 11 Times in 11 Posts
Send a message via Yahoo to melvik
Default

Well this is a sample I've done HTH.
Code:
        //CR Variables
        Empower.reports.foreign        crReportft;
        Empower.reports.foreign_p    crReportfb;
        Empower.reports.vekalat        crReportvt;
        Empower.reports.vekalat_p    crReportvb;
        ConnectionInfo crConnectionInfo;
        TableLogOnInfo crTableLogOnInfo;
        Database crDatabase;
        Tables crTables;
        ParameterFields crParameterFields;
        ParameterField crParameterField;
        ParameterValues crParameterValues;
        ParameterDiscreteValue crParameterDiscreteValue;
        protected CrystalDecisions.Web.CrystalReportViewer CrystalReportViewer1;
        protected CrystalDecisions.Web.CrystalReportViewer CrystalReportViewer2;

        private void Page_Load(object sender, System.EventArgs e)
        {
            string id, type;
            id = Request.QueryString.Get("id");
            type = Request.QueryString.Get("type");

                crReportvt = new Empower.reports.vekalat();
                crConnectionInfo = new ConnectionInfo();
                crConnectionInfo.ServerName = "BORNA";
                crConnectionInfo.DatabaseName = "NewBaz";
                crConnectionInfo.UserID = "report";
                crConnectionInfo.Password = "";

                crDatabase = crReportvt.Database;
                crTables = crDatabase.Tables;

                foreach (CrystalDecisions.CrystalReports.Engine.Table crTable in crTables)
                {        
                    crTableLogOnInfo = crTable.LogOnInfo;
                    crTableLogOnInfo.ConnectionInfo = crConnectionInfo;
                    crTable.ApplyLogOnInfo(crTableLogOnInfo);
                }

                crReportvb = new Empower.reports.vekalat_p();
                crConnectionInfo = new ConnectionInfo();
                crConnectionInfo.ServerName = "BORNA";
                crConnectionInfo.DatabaseName = "NewBaz";
                crConnectionInfo.UserID = "report";
                crConnectionInfo.Password = "";

                crDatabase = crReportvb.Database;
                crTables = crDatabase.Tables;

                foreach (CrystalDecisions.CrystalReports.Engine.Table crTable in crTables)
                {        
                    crTableLogOnInfo = crTable.LogOnInfo;
                    crTableLogOnInfo.ConnectionInfo = crConnectionInfo;
                    crTable.ApplyLogOnInfo(crTableLogOnInfo);
                }
                CrystalReportViewer1.ReportSource = crReportvt;
                CrystalReportViewer2.ReportSource = crReportvb;

            crParameterFields = CrystalReportViewer1.ParameterFieldInfo;
            crParameterField = crParameterFields["@DepForm"];
            crParameterValues = crParameterField.CurrentValues;

            crParameterDiscreteValue = new ParameterDiscreteValue();
            crParameterDiscreteValue.Value = id;
            crParameterValues.Add(crParameterDiscreteValue);

            // Set Second Parameter
            crParameterDiscreteValue = null;
            crParameterField = crParameterFields["@Type"];
            crParameterValues = crParameterField.CurrentValues;

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


Always:),
Hovik Melkomian.
 
Old January 23rd, 2004, 07:35 AM
Registered User
 
Join Date: Jan 2004
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

when you create a blank report, select the data source. Then select your sp from the stored procedures list. If you are not able to see the stored procedures, write what version of CR and what database are u using?
 
Old January 27th, 2005, 07:03 AM
Registered User
 
Join Date: Oct 2004
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to sadiku
Default

how to create crystal report and all objects of it dynamically?






Similar Threads
Thread Thread Starter Forum Replies Last Post
Crystal Report Parameter pass from c# shriji.1111 Crystal Reports 4 June 14th, 2011 11:38 AM
How to pass parameter to a crystal report using c# preetakrish BOOK: Professional Crystal Reports for VS.NET 16 November 19th, 2009 05:26 AM
pass parameter in crystal report srivigdev C# 3 April 14th, 2008 12:11 PM
How to pass Parameter to Crystal Reports 10 shakti_2505270 ASP.NET 2.0 Professional 1 August 30th, 2007 06:01 AM
difficulty in passing parameter to SP in sql happytony Classic ASP Databases 1 July 11th, 2004 05:00 AM





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