Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 415199
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T18:21:28+00:00 2026-05-12T18:21:28+00:00

I am completely lost on this one– I have a .Rpt file that runs

  • 0

I am completely lost on this one–

I have a .Rpt file that runs fine by itself. This report file takes 4 parameters and connects to an oracle database. I have all the database code set up correctly. So i think.

I cannot for the life of me connect this report file to the connection and have the report viewed on my ASP.NET webpage.

When i run this code, no matter what, i get the text invalid pointer where the crystalreportviewer control goes. I am running Crystal Reports 2008 SP2 in an ASP.NET 3.5 project. I am open to people suggesting links to thorough methods of viewing reports (including specifying parameters, connectioninfo, and disposing reportdocument) seeing how I am completely new to this.

I need this process to be dynamic because in the future i will be dynamically setting report files, parameters, database info, etc…

Thank you all in advance.

My Code behind:

using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
using CrystalDecisions.Web;

namespace AMR
{
    public partial class RptParameter2 : System.Web.UI.Page
    {
        ReportDocument crReportDocument;
        ConnectionInfo connectionInfo;
        public enum ReportState { NotSet, FromStart, FromSession,FromPostBack };
        public void Page_Init(object sender, EventArgs e)
        {
            if (!Page.IsPostBack && !Page.IsCallback)
            {
                LoadReport(ReportState.FromStart);

            }
            else
            {
                LoadReport(ReportState.FromPostBack);
            }

        }
        public void LoadReport(ReportState rptState)
        {
            if (rptState != ReportState.FromPostBack)
            {
                if (crReportDocument != null)
                {
                    crReportDocument.Close();
                    crReportDocument.Dispose();
                    crReportDocument = null;
                }
                crReportDocument = new ReportDocument();

                if (rptState == ReportState.FromSession)
                    crReportDocument = (ReportDocument)Session["cr"];
                connectionInfo = new ConnectionInfo();
                ParameterField paramField1 = new ParameterField();
                ParameterField paramField2 = new ParameterField();
                ParameterField paramField3 = new ParameterField();
                ParameterField paramField4 = new ParameterField();
                ParameterFields paramFields = new ParameterFields();
                ParameterDiscreteValue paramDiscreteValue1 = new ParameterDiscreteValue();
                ParameterDiscreteValue paramDiscreteValue2 = new ParameterDiscreteValue();
                ParameterDiscreteValue paramDiscreteValue3 = new ParameterDiscreteValue();
                ParameterDiscreteValue paramDiscreteValue4 = new ParameterDiscreteValue();
                //p1
                paramField1.Name = "Siebel Position";
                paramDiscreteValue1.Value = txtAvailPos.Text;
                paramField1.CurrentValues.Add(paramDiscreteValue1);
                paramFields.Add(paramField1);
                //p2
            paramField2.Name = "DETAIL_LEVEL";
            paramDiscreteValue2.Value = ddlDetailLvl.SelectedValue;
                paramField2.CurrentValues.Add(paramDiscreteValue2);
                paramFields.Add(paramField2);
                //p3
                paramField3.Name = "RPT_MONTH";
                paramDiscreteValue3.Value = ddlMonth.SelectedValue;
                paramField3.CurrentValues.Add(paramDiscreteValue3);
                paramFields.Add(paramField3);
                //p4
                paramField4.Name = "RPT_YEAR";
                paramDiscreteValue4.Value = txtYear.Text;
                paramField4.CurrentValues.Add(paramDiscreteValue4);
                paramFields.Add(paramField4);
                //loading
                CrystalReportViewer1.ReportSource = crReportDocument;
                crReportDocument.Load(Server.MapPath("~/myreport.rpt"));
                connectionInfo.ServerName = "myserver";

                connectionInfo.DatabaseName = System.Configuration.ConfigurationSettings.AppSettings["Crystal_Database"];
                connectionInfo.UserID = System.Configuration.ConfigurationSettings.AppSettings["Crystal_Username"];
                connectionInfo.Password = System.Configuration.ConfigurationSettings.AppSettings["Crystal_Password"];

                SetDBLogonForReport(connectionInfo);
                CrystalReportViewer1.ParameterFieldInfo = paramFields;
                CrystalReportViewer1.EnableDatabaseLogonPrompt = false;
                CrystalReportViewer1.EnableParameterPrompt = false;
                CrystalReportViewer1.Visible = true;
                Session["cr"] = crReportDocument;
            }
            else//reportstate from postback
            {
                CrystalReportViewer1.ReportSource = (ReportDocument)Session["cr"];
            }
        }
        private void SetDBLogonForReport(ConnectionInfo connectionInfo)
        {
            TableLogOnInfos tableLogOnInfos = CrystalReportViewer1.LogOnInfo;
            foreach (TableLogOnInfo tableLogOnInfo in tableLogOnInfos)
            {
                tableLogOnInfo.ConnectionInfo = connectionInfo;

            }



        }
        public void btnyclick(object sender, EventArgs e)
        {
            LoadReport(ReportState.FromSession);

        }
        public void btnClose_Click(object sender, EventArgs e)
        {

        }
    }
}

My Page:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="RptParameter2.aspx.cs" Inherits="AMR.RptParameter2" %>
<%@ Register Assembly="CrystalDecisions.Web, Version=12.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"  Namespace="CrystalDecisions.Web" TagPrefix="CR"  %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Crystal Test</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <div class="floatbox">

 <p>  &nbsp;  Enter the Employee Position : <asp:TextBox ID="txtAvailPos" runat="server" Width="125" > </asp:TextBox> 
 <p style="margin-left: 80px"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;                 Detail Level : <asp:DropDownList ID="ddlDetailLvl" runat="server"  >
                                                                                                <asp:ListItem Text="SELF" Value="SELF" Selected="True"></asp:ListItem>
                                                                                                <asp:ListItem Text="TEAM" Value="TEAM" ></asp:ListItem>
                                                                                             </asp:DropDownList> </p>  
 <p style="margin-left: 120px">&nbsp;&nbsp;&nbsp;                        Month : <asp:DropDownList ID="ddlMonth" runat="server" >
                                                                                    <asp:ListItem Text="01" Value="01" ></asp:ListItem>
                                                                                    <asp:ListItem Text="02" Value="02" ></asp:ListItem>
                                                                                    <asp:ListItem Text="03" Value="03" ></asp:ListItem>
                                                                                    <asp:ListItem Text="03" Value="04" ></asp:ListItem>
                                                                                    <asp:ListItem Text="05" Value="05" ></asp:ListItem>
                                                                                    <asp:ListItem Text="06" Value="06" ></asp:ListItem>
                                                                                    <asp:ListItem Text="07" Value="07" ></asp:ListItem>
                                                                                    <asp:ListItem Text="08" Value="08" ></asp:ListItem>
                                                                                    <asp:ListItem Text="09" Value="09" ></asp:ListItem>
                                                                                    <asp:ListItem Text="10" Value="10" ></asp:ListItem>
                                                                                    <asp:ListItem Text="11" Value="11" ></asp:ListItem>
                                                                                    <asp:ListItem Text="12" Value="12" ></asp:ListItem>
                                                                                 </asp:DropDownList> </p>  
 <p style="margin-left: 120px">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;                         Year : <asp:TextBox ID="txtYear" runat="server" Text="2009" Enabled="false" Width="35" > </asp:TextBox></p>  
<p style="margin-left: 160px"> <asp:Button runat="server" ID="btny" Text="Show Report" OnClick="btnyclick" /> </p>
<asp:Button runat="server" ID="btnclose" Text="Close" OnClick="btnClose_Click" /><br />
    <CR:CrystalReportViewer ID="CrystalReportViewer1" runat="server" 
            AutoDataBind="true"   />
    </div>
    </div>
    </form>
</body>
</html>
  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T18:21:28+00:00Added an answer on May 12, 2026 at 6:21 pm

    It turns out that the report we were using was an older Crystal Reports (8 i think) report that was using a .qry file. After we converted the query to a command object (in crystal) everything worked!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im completely lost with this one. Ok so I create a button with CSS,
I'm completely lost on this one: System.getProperty(user.home) and System.getProperty(user.name) returns a questionmark ?. System-Specs:
Hey all, I am completely lost on this one. I found a code snippet
Hey I am completely lost with this one. Basically the website i'm working on
I'm completely lost on this, I'm not sure what is causing this error: Fatal
Some variants of this question have been asked before, but not this exact one.
I have an assignment to correct an ambiguous BNF, but I am completely lost.
I'm completely lost as to how or why this error is displaying when I
I've googled tutorials the last couple day on this and I'm completely lost/stuck. I
We've completely lost our repository and we have 8 developers with uncomitted changes. Restoring

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.