473,386 Members | 1,630 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Cannot close connection of crystal report

In my ASP.NET page, I have 2 checkboxes for users to choose which
crystal report they want to display. These two reports use different
tables. If report1 has been choosen and displayed in the crystal
report, then I cannot check another checkbox to display report2
afterwards. If I close the website and open again, I can choose report2
and display as crystal report correct, but now I cannot check the
checkbox1 to display report 1 afterwards.
This is the error message:

Error in File
C:\DOCUME~1\CHRISHO\ASPNET\LOCALS~1\Temp\temp_c58d 8a47-521f-4540-bf93-d4f493584892.rpt:
Error in formula <Record_Selection>. '{INUTMTI_TERM.part_user} =
{?in_user} and ' This field name is not known.
The table INUTMTI_TERM is the table used by report 1, not by report 2,
but it's trying to access this table when I choose to display report2.
Although I try to close the report in the Page_Unload() method, somehow
the crystal report connection would not close and cause this problem.
I'm attaching my code here (some code deleted to improve readability).
Please give me some hint on how to solve this problem.

Thanks,
Christine
namespace inventory
{

public class userreqterm : System.Web.UI.Page
{
protected CrystalDecisions.Web.CrystalReportViewer
CrystalReportViewer1;
userreqtermCR crReportDocument;
userreqtermWCR crReportDocument2;
TableLogOnInfo crTableLogOnInfo = new TableLogOnInfo();
ConnectionInfo crConnectionInfo = new ConnectionInfo();
TableLogOnInfo crTableLogOnInfo2 = new TableLogOnInfo();
CrystalDecisions.CrystalReports.Engine.Database crDatabase;
CrystalDecisions.CrystalReports.Engine.Database crDatabase2;
CrystalDecisions.CrystalReports.Engine.Tables crTables2;
private void Page_Load(object sender, System.EventArgs e)
{
crReportDocument = new userreqtermCR();
crReportDocument2 = new userreqtermWCR();
crConnectionInfo.ServerName = "x.x.x.x";
crConnectionInfo.DatabaseName = "xxxx";
crConnectionInfo.UserID = "xxxx";
crConnectionInfo.Password = "xxxx";
crDatabase = crReportDocument.Database;
crTables = crDatabase.Tables;
crDatabase2 = crReportDocument2.Database;
crTables2 = crDatabase2.Tables;

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

foreach(CrystalDecisions.CrystalReports.Engine.Tab le crTable2 in
crTables2)
{
crTableLogOnInfo2 = crTable2.LogOnInfo;
crTableLogOnInfo2.ConnectionInfo = crConnectionInfo;
crTable2.ApplyLogOnInfo(crTableLogOnInfo2);
}
}

private void Page_Unload(object sender, System.EventArgs e)
{
crReportDocument.Close();
crReportDocument.Dispose();
crReportDocument2.Close();
crReportDocument2.Dispose();
crReportDocument = null;
crReportDocument2 = null;
crTableLogOnInfo = null;
crTableLogOnInfo2 = null;
crConnectionInfo=null;
crDatabase =null;
crTables = null;
crDatabase2 = null;
crTables2 = null;
CrystalReportViewer1.Dispose();
CrystalReportViewer1 = null;
}
private void run_Click(object sender, System.EventArgs e)
{
SqlCommand command = new SqlCommand("inutmti_upd_chrg",connection);
command.Connection=connection;
command.CommandType=CommandType.StoredProcedure;
command.CommandText = "inutmti_upd_chrg";
command.Parameters.Add(new
SqlParameter("@in_user",SqlDbType.VarChar, 5));
command.Parameters["@in_user"].Value=department.SelectedValue.ToString();
command.Parameters.Add(new
SqlParameter("@in_yyyymmdd",SqlDbType.DateTime, 8));
command.Parameters["@in_yyyymmdd"].Value=termenddate.Text.ToString();
connection.Open();
command.ExecuteNonQuery();
connection.Close();

ParameterFields paramFields = new ParameterFields();
ParameterField user = new ParameterField();
ParameterField dept = new ParameterField();
ParameterField yyyymmdd = new ParameterField();
ParameterDiscreteValue dcuser = new ParameterDiscreteValue();
ParameterDiscreteValue dcdept = new ParameterDiscreteValue();
ParameterDiscreteValue dcyyyymmdd = new ParameterDiscreteValue();

dept.ParameterFieldName = "in_dept";
dcdept.Value = department.SelectedItem.Text.ToString();
dept.CurrentValues.Add(dcdept);

user.ParameterFieldName = "in_user";
dcuser.Value = department.SelectedValue.ToString();
user.CurrentValues.Add(dcuser);

yyyymmdd.ParameterFieldName = "in_yyyymmdd";
dcyyyymmdd.Value = termenddate.Text.ToString();
yyyymmdd.CurrentValues.Add(dcyyyymmdd);

paramFields.Add(user);
paramFields.Add(dept);
paramFields.Add(yyyymmdd);

if(option.SelectedValue.ToString()=="L")
{
CrystalReportViewer1.ReportSource = crReportDocument;
CrystalReportViewer1.ParameterFieldInfo = paramFields;
CrystalReportViewer1.Visible=true;
CrystalReportViewer1.DataBind();

}
else if(option.SelectedValue.ToString()=="W")
{
CrystalReportViewer1.ReportSource = crReportDocument2;
CrystalReportViewer1.ParameterFieldInfo = paramFields;
CrystalReportViewer1.Visible=true;
CrystalReportViewer1.DataBind();

}

crTableLogOnInfo = null;
crTableLogOnInfo2 = null;
crConnectionInfo=null;
crDatabase =null;
crTables = null;
crDatabase2 = null;
crTables2 = null;
}
}
}

Jan 13 '06 #1
0 3877

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Meral Agceli via .NET 247 | last post by:
A crystal report is developed using Crystal 8.5 and a trustedconnection to a SQL Server database. I'm trying to display thisreport in Crystal Report Viewer using VB.NET. When theapplication is run, I...
0
by: Atif | last post by:
Hi All My problem is not related with this group BUT i have got a clue from here that's why i am posting this question over here. I am using Crystal Reports 9 with MySQL and SQL Server....
2
by: news.microsoft.com | last post by:
Hi, (Vb.net 2003 and Crystal report.net) If my application already has a connection, how can I use it in the crystal report. I have designed some reports using the designer with vs.net03,...
7
by: Bernie Yaeger | last post by:
I can't believe that there aren't lots of developers who: 1. create a crystal report that connects to sql server 2. calls the report using the crystalreportviewer control to view it and then,...
7
by: Henry | last post by:
I am writing a Windows forms VB.Net/MS SQL application via VS 2003 that utilizes Crystal Reports. I want to be able to dynamically set the report data source at run time. I'm trying to change...
1
by: abc | last post by:
Our web project is used VS2003 and Crystal Reports for Visual Studio.NET. There have reports that directly call to sql server's stored procedure. I also call SetDatabaseLogon method to change user...
2
by: Syrenic | last post by:
Hi Everyone, I recently developed an application using VB6 calling Crystal Report bundled with VB.NET. Problem lies here, whenever i make a call for a report view from MS Access in VB.NET....
1
Shashi Sadasivan
by: Shashi Sadasivan | last post by:
Hi, I have bumped into this issue where my application (which consistently reads the database) has to also create a crsytal report when requested. The crystal repost uses the same connection string...
0
by: Mark Gold | last post by:
Hi! We have a VB application using Crystal Reports 6 that has worked successfully on hundreds of systems for over 10 years. Now, on one network, the application and access database does not close....
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.