kimmie8000
asked on
Grabbing Parameters from Crystal XI in C# more than one parameter is declared in the report. I am populating values from Request.QueryString["URL_RECON_DTTM"].ToString();
I am trying to bring in a 2nd parameter from a crystal report that was given to me. I need to run this report though an url. Whatever the given values are in the URL, I am to grab them from there and generate the report. This works fine for one parameter. However, I cannot get it to work for two parameter fields. I can put the values into the an array. However, I cannot get Crystal to reconconize that there are two parameters. Please help soon. I am running out of ideals.
The url would like like this:
http://localhost:4256/MedRecReports/ArchiveReport.aspx?URL_PERSON_NUM=131&URL_RECON_DTTM=1/28/2008 3:13:03 PM
The URL_PERSON_NUM is a string.
The URL_RECON_DTTM is a DateTime in the Crystal report.
(ERROR MESSAGE)
An exception of type 'System.ArgumentOutOfRange Exception' occurred in CrystalDecisions.Shared.dl l but was not handled in user code
Additional information: Specified argument was out of the range of valid values.
The url would like like this:
http://localhost:4256/MedRecReports/ArchiveReport.aspx?URL_PERSON_NUM=131&URL_RECON_DTTM=1/28/2008 3:13:03 PM
The URL_PERSON_NUM is a string.
The URL_RECON_DTTM is a DateTime in the Crystal report.
(ERROR MESSAGE)
An exception of type 'System.ArgumentOutOfRange
Additional information: Specified argument was out of the range of valid values.
using System;
using Microsoft.VisualBasic;
using System.Data;
using System.Configuration;
using System.Collections;
using System.ComponentModel;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Web.Configuration;
using System.Reflection;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
using CrystalDecisions.ReportSource;
using CrystalDecisions.Web;
public partial class ArchiveReport : System.Web.UI.Page
{
private const string PARAMETER_FIELD_NAME = "URL_PERSON_NUM";
private const string PARAMETER_FIELD_NAME1 = "URL_RECON_DTTM";
protected void Page_Load(object sender, EventArgs e)
{
}
private void Page_Init(object sender, EventArgs e)
{
// Set Session Variable for Screen Time Out
Session["AppAccessDate"] = DateTime.Now;
ConfigureCrystalReports();
}
private void ConfigureCrystalReports()
{
// The following code must be placed in every GASF Web Page
// Compare current time to last time the app was accessed.
// If time in minutes from config field "HIPAAScreenRefresh" has elapsed
// return to GASF Home Page screen.
System.TimeSpan diff = DateTime.Now.Subtract((DateTime)Session["AppAccessDate"]);
int totalSeconds = (diff.Minutes) * 60 + diff.Seconds; // total difference in seconds
if (totalSeconds > (Convert.ToInt32(WebConfigurationManager.AppSettings["HIPAAScreenRefresh"]) * 60))
{
Response.Redirect(WebConfigurationManager.AppSettings["Archive"]);
}
else
{
// Refresh web page after time set in Config File + 10 seconds.
// Time Set in Config File in minutes is multipled by 60 to obtain seconds.
// When the page is refreshed and time time has expired since the last update
// the user is returned to the Weclome Page.
int screenRefreshSeconds = Convert.ToInt32(WebConfigurationManager.AppSettings["HIPAAScreenRefresh"]) * 60 + 10;
this.Response.AppendHeader("Refresh", screenRefreshSeconds.ToString());
}
// Database connection stuff
ConnectionInfo connectionInfo = new ConnectionInfo();
connectionInfo.ServerName = "GA_Critical_info";
connectionInfo.DatabaseName = "GA_Critical_info";
connectionInfo.UserID = "GGSCRITICAL";
connectionInfo.Password = "GGSCRITICAL";
ArrayList arrayList = new ArrayList();
string reportPath = Server.MapPath("~/reports/Archive/admitArchive.rpt");
crystalReportViewer.ReportSource = reportPath;
SetDBLogonForReport(connectionInfo);
ParameterFields parameterFields = crystalReportViewer.ParameterFieldInfo;
if (!IsPostBack)
{
// Store User ID from Query String in ViewState
if (Request.QueryString["URL_PERSON_NUM"] == null)
{
Session["URL_PERSON_NUM"] = "0";
}
else
{
Session["URL_PERSON_NUM"] = Request.QueryString["URL_PERSON_NUM"].ToString();
Session["URL_RECON_DTTM"] = Request.QueryString["URL_RECON_DTTM"];
string testURL = Request.QueryString["URL_PERSON_NUM"].ToString();
string testURLD = Request.QueryString["URL_RECON_DTTM"].ToString();
}
arrayList.Add(Convert.ToInt32(Request.QueryString["URL_PERSON_NUM"]));
// arrayList.Add(Convert.ToInt32(Request.QueryString["URL_RECON_DTTM"]));
Session["arrayList"] = arrayList;
}
else
{
if (Session["arrayList"] == null)
{
Response.Redirect(WebConfigurationManager.AppSettings["Archive"]);
}
arrayList = (ArrayList)Session["arrayList"];
}
SetCurrentValuesForParameterField(parameterFields, arrayList);
}
private void SetDBLogonForReport(ConnectionInfo connectionInfo)
{
TableLogOnInfos tableLogOnInfos = crystalReportViewer.LogOnInfo;
foreach (TableLogOnInfo tableLogOnInfo in tableLogOnInfos)
{
tableLogOnInfo.ConnectionInfo = connectionInfo;
}
}
private void SetCurrentValuesForParameterField(ParameterFields parameterFields, ArrayList arrayList)
{
ParameterValues currentParameterValues = new ParameterValues();
foreach (object submittedValue in arrayList)
{
ParameterDiscreteValue parameterDiscreteValue = new ParameterDiscreteValue();
parameterDiscreteValue.Value = submittedValue.ToString();
currentParameterValues.Add(parameterDiscreteValue);
}
ParameterField parameterField = parameterFields["URL_PERSON_NUM", "URL_RECON_DTTM"];
parameterField.CurrentValues = currentParameterValues;
}
private ArrayList GetDefaultValuesFromParameterField(ParameterFields parameterFields)
{
ParameterField parameterField = parameterFields["URL_PERSON_NUM", "URL_RECON_DTTM"];
ParameterValues defaultParameterValues = parameterField.DefaultValues;
ArrayList arrayList = new ArrayList();
foreach (ParameterValue parameterValue in defaultParameterValues)
{
if (!parameterValue.IsRange)
{
ParameterDiscreteValue parameterDiscreteValue = (ParameterDiscreteValue)parameterValue;
arrayList.Add(parameterDiscreteValue.Value.ToString());
}
}
return arrayList;
}
/// <summary>
/// The method below is not needed. We commented it out for potential future use.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
//protected void redisplay_Click(object sender, EventArgs e)
//{
// ArrayList arrayList = new ArrayList();
// foreach (ListItem item in defaultParameterValuesList.Items)
// {
// if (item.Selected)
// {
// arrayList.Add(item.Value);
// }
// }
// Session["arrayList"] = arrayList;
// ConfigureCrystalReports();
//}
protected void LinkButton1_Click(object sender, EventArgs e)
{
// Append URL for Admit App
string url = string.Empty;
string queryString = string.Empty;
url = WebConfigurationManager.AppSettings["Archive"];
// If report was started with a UserID Link to
// Home Page of the GASF Application
if (Session["URL_PERSON_NUM"].ToString() == "0")
{
queryString = "RX_ADMIT_RECON.aspx";
}
else
{
queryString = "RX_ADMIT_RECON.aspx?URL_PERSON_NUM=" + Session["URL_PERSON_NUM"].ToString();
}
Response.Redirect(url + queryString);
}
protected void LinkButton2_Click(object sender, EventArgs e)
{
Response.Write("<script>window.close()</script>");
}
}
ASKER
Right now, I am just trying to pass two parameters. One does need to be a date and time parameter. I have gotten this far with totally trying to turn the code around to just get the two parms to pass. Now the Crystal report tells me that I am not generating any parameters. At this point, I am not sure what I am doing wrong.
ArchiveAdmitReport = new ReportDocument();
string reportPath = Server.MapPath("~/reports/ Archive/ad mitArchive .rpt");
crystalReportViewer.Report Source = reportPath;
ArchiveAdmitReport.Load(re portPath);
//Connect to the ODBC Crystal report.
SetDBLogonForReport(connec tionInfo);
ParameterFields parameterFields = crystalReportViewer.Parame terFieldIn fo;
if (!IsPostBack)
{
// Store User ID from Query String in ViewState
if (Request.QueryString["URL_ PERSON_NUM "] == null)
{
Session["URL_PERSON_NUM"] = "0";
}
else
{
Session["URL_PERSON_NUM"] = Request.QueryString["URL_P ERSON_NUM" ].ToString ();
Session["URL_RECON_DTTM"] = Request.QueryString["URL_R ECON_DTTM" ];
string testURL = Request.QueryString["URL_P ERSON_NUM" ].ToString ();
string testURLD = Request.QueryString["URL_R ECON_DTTM" ].ToString ();
}
arrayList.Add(Convert.ToIn t32(Reques t.QueryStr ing["URL_P ERSON_NUM" ]));
arrayList.Add(Convert.ToIn t32(Reques t.QueryStr ing["URL_R ECON_DTTM" ]));
Session["arrayList"] = arrayList;
}
else
{
if (Session["arrayList"] == null)
{
Response.Redirect(WebConfi gurationMa nager.AppS ettings["A rchive"]);
}
arrayList = (ArrayList)Session["arrayL ist"];
}
SetCurrentValuesForParamet erField(Ar chiveAdmit Report);
//SetCurrentValuesForParam eterField( parameterF ields, arrayList);
}
private void SetDBLogonForReport(Connec tionInfo connectionInfo)
{
TableLogOnInfos tableLogOnInfos = crystalReportViewer.LogOnI nfo;
foreach (TableLogOnInfo tableLogOnInfo in tableLogOnInfos)
{
tableLogOnInfo.ConnectionI nfo = connectionInfo;
}
}
private void SetCurrentValuesForParamet erField(Re portDocume nt reportDocument)
{
ParameterValues currentParameterValues = new ParameterValues();
ParameterDiscreteValue parameterDiscreteValue = new ParameterDiscreteValue();
parameterDiscreteValue.Val ue = Request.QueryString["URL_P ERSON_NUM" ].ToString ();
currentParameterValues.Add (parameter DiscreteVa lue);
ParameterFieldDefinitions parameterFieldDefinitions = reportDocument.DataDefinit ion.Parame terFields;
ParameterFieldDefinition parameterFieldDefinition = parameterFieldDefinitions[ "URL_PERSO N_NUM"];
parameterFieldDefinition.A pplyCurren tValues(cu rrentParam eterValues );
parameterDiscreteValue.Val ue = Request.QueryString["URL_R ECON_DTTM" ].ToString ();
currentParameterValues.Add (parameter DiscreteVa lue);
ParameterFieldDefinition parameterFieldDefinition2 = parameterFieldDefinitions[ "URL_RECON _DTTM"];
parameterFieldDefinition.A pplyCurren tValues(cu rrentParam eterValues );
crystalReportViewer.Report Source = ArchiveAdmitReport;
}
ArchiveAdmitReport = new ReportDocument();
string reportPath = Server.MapPath("~/reports/
crystalReportViewer.Report
ArchiveAdmitReport.Load(re
//Connect to the ODBC Crystal report.
SetDBLogonForReport(connec
ParameterFields parameterFields = crystalReportViewer.Parame
if (!IsPostBack)
{
// Store User ID from Query String in ViewState
if (Request.QueryString["URL_
{
Session["URL_PERSON_NUM"] = "0";
}
else
{
Session["URL_PERSON_NUM"] = Request.QueryString["URL_P
Session["URL_RECON_DTTM"] = Request.QueryString["URL_R
string testURL = Request.QueryString["URL_P
string testURLD = Request.QueryString["URL_R
}
arrayList.Add(Convert.ToIn
arrayList.Add(Convert.ToIn
Session["arrayList"] = arrayList;
}
else
{
if (Session["arrayList"] == null)
{
Response.Redirect(WebConfi
}
arrayList = (ArrayList)Session["arrayL
}
SetCurrentValuesForParamet
//SetCurrentValuesForParam
}
private void SetDBLogonForReport(Connec
{
TableLogOnInfos tableLogOnInfos = crystalReportViewer.LogOnI
foreach (TableLogOnInfo tableLogOnInfo in tableLogOnInfos)
{
tableLogOnInfo.ConnectionI
}
}
private void SetCurrentValuesForParamet
{
ParameterValues currentParameterValues = new ParameterValues();
ParameterDiscreteValue parameterDiscreteValue = new ParameterDiscreteValue();
parameterDiscreteValue.Val
currentParameterValues.Add
ParameterFieldDefinitions parameterFieldDefinitions = reportDocument.DataDefinit
ParameterFieldDefinition parameterFieldDefinition = parameterFieldDefinitions[
parameterFieldDefinition.A
parameterDiscreteValue.Val
currentParameterValues.Add
ParameterFieldDefinition parameterFieldDefinition2 = parameterFieldDefinitions[
parameterFieldDefinition.A
crystalReportViewer.Report
}
ASKER
I figured this out. thnks for letting me post.
What is the solution?
mlmcc
mlmcc
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I think you need to pass a datettime value not a string
mlmcc