Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

my report has the same data everytime I access it

Posted on 2004-04-16
3
Medium Priority
?
313 Views
Last Modified: 2008-03-06
In my web app, my report has the same data everytime I access it. I DO NOT have the Save Data with Report checked.  The only data that comes up is the data that gets displayed in design time.

I am updating my parameters but when i trace the stored procedure calls the parameters are not updated.

The data doesn't update whether I use crystal viewer or generate the report in pdf.

I am using crystal 9 advanced, Windows 2003, SQL Server. I have been at this for sometime now and cannot get it figured out!

Any help would be great.

Thanks, Jordan


using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.IO;
using System.Collections.Specialized;
using System.Configuration;

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

using JHS.App.Reports.CrystalFiles;

namespace JHS.App.Reports
{
      /// <summary>
      /// Summary description for InmateReport.
      /// </summary>
      public class InmateReport : System.Web.UI.Page
      {

            protected ReportDocument crReportDocument = new CustomerGeneralReport();

            protected string _ID1;
            protected string _ID2;
            protected string _ID3;

            protected string url;

            ConnectionInfo crConnectionInfo;
            TableLogOnInfo crtableLogoninfo;
            protected CrystalDecisions.Web.CrystalReportViewer CrystalReportViewer1;
            Tables crTables;

            private void Page_Load(object sender, System.EventArgs e)
            {
                  // Put user code to initialize the page here

                  url = ConfigurationSettings.AppSettings["URL"];
                  Response.Expires=-1;

                  try
                  {

                  HttpContext ctx = HttpContext.Current;
                  HttpCookie inCookie = ctx.Request.Cookies["2JHS3"];
                  if(inCookie != null)
                  {
                        _ID1= inCookie.Values["ID1"].ToString();
                        _ID2= inCookie.Values["ID2"].ToString();
                        _ID3= inCookie.Values["ID3"].ToString();
                  }


                        crConnectionInfo = new ConnectionInfo();
                        crReportDocument.SetParameterValue("@param1", _ID1);
                        crReportDocument.SetParameterValue("@param2", _ID2);
                        crReportDocument.SetParameterValue("@param3", _ID3);

      
                        crConnectionInfo.ServerName = ConfigurationSettings.AppSettings["SERVER_NAME"];
                        crConnectionInfo.DatabaseName = ConfigurationSettings.AppSettings["DBNAME"];
                        crConnectionInfo.UserID = ConfigurationSettings.AppSettings["USERID"];
                        crConnectionInfo.Password = ConfigurationSettings.AppSettings["PASSWORD"];

                        crTables = crReportDocument.Database.Tables;

                        //Loop through each table in the report and apply the
                        //LogonInfo information
                        foreach (CrystalDecisions.CrystalReports.Engine.Table crTable in crTables)
                        {
                              crtableLogoninfo = crTable.LogOnInfo;
                              crtableLogoninfo.ConnectionInfo = crConnectionInfo;
                              crTable.ApplyLogOnInfo(crtableLogoninfo);
                              crTable.Location = crConnectionInfo.DatabaseName + ".dbo." + crTable.Location.Substring(crTable.Location.LastIndexOf(".") + 1);
                        }

                        CrystalReportViewer1.ReportSource = crReportDocument;
                        CrystalReportViewer1.Visible = true;
                        /*
                        System.IO.Stream st;
                        st = crReportDocument.ExportToStream(ExportFormatType.PortableDocFormat);

                        Response.ClearContent();
                        Response.ClearHeaders();
                        Response.Expires=-1;
                        Response.ContentType = "application/PDF";
                        byte[] b = new byte[st.Length];
                        st.Read(b,0,(int) st.Length);
                        Response.BinaryWrite(b);
                        crReportDocument.Close();
                        Response.Flush();
                        Response.Close();
                        */
                  }
                        catch (FormatException ex)
                  {
                        Response.Write(ex.ToString());
      }
0
Comment
Question by:jrmcdona
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 42

Accepted Solution

by:
frodoman earned 300 total points
ID: 10846017
It looks like you're getting the parameter values from a cookie.  Have you verified that the values in your code are changing correctly?  I'm thinking there could be a caching problem in your browser that may be sending the old params?
0
 

Author Comment

by:jrmcdona
ID: 10846146
Well, some weird stuff is going on.

I was opening my reports in a new browswer, which I do on my production server currently and everything is great.

I set up a new server with Windows 2003 and things are acting up now.

I changed my reports to not spawn a new window and I also just now added:

crReportDocument.Refresh();

This has made my reports work just great. However, when I return to spawning the reports in a new window the cookies are not being found. I don't understand at all what is causing that.  It works fine.  I am wondering if it has something to do with 2003 and IIS6?

THanks,
Jordan

0
 
LVL 1

Assisted Solution

by:Arnee_Senthil
Arnee_Senthil earned 75 total points
ID: 10856768
I think the problem is not with the execution of Crystal Rpt. Its due to some default options set during designing of Crystal Rpt.

If you used ADO/RDO/DAO to design a report, you need to paste a SQL qry during design time.
While executing this query thro Crystal report to bring "Data Fields" in to the report, Cr-Rpt Designer connects to DB and executes the SQL that you used during design time. That SQL may return a set of data, and that data will always be displayed in the Report during runtime. (I THINK THIS IS THE PROBLEM YOU ARE FACING)

* To rectify it open the report in Open the Rpt in "32 bit Crystal Report Designer".
* Verify the option in "File Menu>>> Save Data with Report".
   By default this is in checked state.
   Uncheck this option and execute as you did before.


This will solve the issue.

Arnee...
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Crystal Reports: 5 Tests for Top Performance It is complete, your masterpiece report.  Not only does it meet your customer’s expectations, it blows them out the water, all they want is beautifully summarised and displayed in a myriad of ways. …
Hot fix for .Net Crystal Reports 10.2.3600.0 to fix problems with sub reports running on 64 bit operating systems ISSUE: Reports which contain subreports fail with error "Missing Parameter Value" DEPLOYMENT SERVER OS: Windows 2008 with 64 bi…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question