在服务器托管后使用Crystal Report在ASP.NET中打印问题 [英] Print problem in asp.net using crystal report after hosting in server
问题描述
亲爱的所有人,
我创建了一个Web应用程序,即使用Cyrstal报表打印数据.
我已经使用数据集在Crystal报表中显示了数据...运行良好.
创建此应用程序后,我已将此Web应用程序托管到IIS Webserver中.
在服务器中托管后无法打印水晶报表数据.
我可以从本地PC打印...但是在服务器托管后无法打印.
请帮助我,并为此提供一个好的解决方案,
永远谢谢!!
Dear All,
I have Created a Web Application, in that am using cyrstal reports to print the data.
I have displayed data in crystal report using dataset...its running fine.
after creating this application i have hosted this web application into IIS Webserver.
am unable to print the crystal report data after hosting in server.
I can print from my local pc...but unable to print after hosting in server.
Please help me, and give me a good solution for this,
Thanks for ever !!
推荐答案
这是我的设计页面
====================
this is my Design Page
=====================
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="SelectedReport.aspx.cs" Inherits="Users_SelectedReport" %>
<%@ Register Assembly="CrystalDecisions.Web, Version=10.5.3700.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"
Namespace="CrystalDecisions.Web" TagPrefix="CR" %>
<%@ Register Assembly="Microsoft.ReportViewer.WebForms, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
Namespace="Microsoft.Reporting.WebForms" TagPrefix="rsweb" %>
<!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>Selected | Print Report</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<CR:CrystalReportViewer ID="CrystalReportViewer1" runat="server" AutoDataBind="true" />
</div>
</form>
</body>
</html>
这是我的代码页
===================
使用系统;
使用System.Configuration;
使用System.Data;
使用System.Linq;
使用System.Web;
使用System.Web.Security;
使用System.Web.UI;
使用System.Web.UI.HtmlControls;
使用System.Web.UI.WebControls;
使用System.Web.UI.WebControls.WebParts;
使用System.Collections;
使用System.Xml.Linq;
使用System.Data.SqlClient;
使用CrystalDecisions.Shared;
使用CrystalDecisions.CrystalReports.Engine;
公共局部类Users_SelectedReport:System.Web.UI.Page
{
受保护的void Page_Load(对象发送者,EventArgs e)
{
ReportDocument rptDoc = new ReportDocument();
//航班ds =新的Flights(); //.xsd文件名
SelectedDataSet ds =新的SelectedDataSet();
//DataTable dt = new DataTable();
////只需设置数据表的名称
//dt.TableName =水晶报表示例";
//dt = Session ["dataTable"]; //此功能位于此功能下方
//ds.Tables[0].Merge(dt);
//您的.rpt文件路径将在以下
rptDoc.Load(Server.MapPath("SelectedCrystalReportColumn.rpt")));
//将数据集设置为报表查看器.
rptDoc.SetDataSource(Session ["dataTable"]);
CrystalReportViewer1.ReportSource = rptDoc;
}
公共DataTable getAllOrders()
{
//连接字符串用数据库服务器名称替换"databaseservername"
字符串sqlCon ="server = hyd01; Integrated Security = True; INITIAL CATALOG = infoDB; PERSIST SECURITY INFO = FALSE; Connect Timeout = 0";
SqlConnection Con =新的SqlConnection(sqlCon);
SqlCommand cmd =新的SqlCommand();
DataSet ds = null;
SqlDataAdapter适配器;
试试
{
Con.Open();
//存储过程调用.它已经在示例数据库中.
cmd.CommandText ="SELECT [ClearanceNumber],[CodeFlightId],DateLastChange,DateValidFrom,DateValidTo,[ReservationNo],[AircraftType],[CityCode],[days_t]为[Days] FROM [Flight],其中[ClearanceNumber] ='' "+ Request.QueryString [" clr] +"'';
cmd.CommandType = CommandType.Text;
cmd.Connection = Con;
ds = new DataSet();
adapter = new SqlDataAdapter(cmd);
adapter.Fill(ds,"Users");
}
catch(ex ex例外)
{
抛出新的Exception(ex.Message);
}
终于
{
cmd.Dispose();
如果(Con.State!= ConnectionState.Closed)
Con.Close();
}
返回ds.Tables [0];
}
}
请帮助我,谢谢.
THis is my code page
====================
using System;
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.Collections;
using System.Xml.Linq;
using System.Data.SqlClient;
using CrystalDecisions.Shared;
using CrystalDecisions.CrystalReports.Engine;
public partial class Users_SelectedReport : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
ReportDocument rptDoc = new ReportDocument();
//Flights ds = new Flights(); // .xsd file name
SelectedDataSet ds = new SelectedDataSet();
//DataTable dt = new DataTable();
//// Just set the name of data table
//dt.TableName = "Crystal Report Example";
//dt = Session["dataTable"]; //This function is located below this function
//ds.Tables[0].Merge(dt);
// Your .rpt file path will be below
rptDoc.Load(Server.MapPath("SelectedCrystalReportColumn.rpt"));
//set dataset to the report viewer.
rptDoc.SetDataSource(Session["dataTable"]);
CrystalReportViewer1.ReportSource = rptDoc;
}
public DataTable getAllOrders()
{
//Connection string replace ''databaseservername'' with your db server name
string sqlCon = "server=hyd01; Integrated Security=True;INITIAL CATALOG=infoDB;PERSIST SECURITY INFO=FALSE;Connect Timeout=0";
SqlConnection Con = new SqlConnection(sqlCon);
SqlCommand cmd = new SqlCommand();
DataSet ds = null;
SqlDataAdapter adapter;
try
{
Con.Open();
//Stored procedure calling. It is already in sample db.
cmd.CommandText = "SELECT [ClearanceNumber],[CodeFlightId],DateLastChange,DateValidFrom,DateValidTo,[ReservationNo],[AircraftType],[CityCode],[days_t] as [Days] FROM [Flight] where [ClearanceNumber] = ''" + Request.QueryString["clr"] + "''";
cmd.CommandType = CommandType.Text;
cmd.Connection = Con;
ds = new DataSet();
adapter = new SqlDataAdapter(cmd);
adapter.Fill(ds, "Users");
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
finally
{
cmd.Dispose();
if (Con.State != ConnectionState.Closed)
Con.Close();
}
return ds.Tables[0];
}
}
Please help me, Thanks in ADVANCE.
这篇关于在服务器托管后使用Crystal Report在ASP.NET中打印问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!