Crystal Reports登录无法在生产中使用 [英] Crystal Reports login not working in production

查看:114
本文介绍了Crystal Reports登录无法在生产中使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先,我正在开发中,但是当我发布到生产Web服务器时,不是生成报告,而是再次要求我提供登录凭据.
这是我在文件后面的全部代码的快照:

Firstly, I have this working in development, however when I publish to the production webserver, instead of generating the report, it asks me for login credentials again.
Here is a snapshot of my entire code behind file:

public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if ((ViewState["ParametersShown"] != null) &&
(ViewState["ParametersShown"].ToString() == "True"))
{
ReportListing myListing = new ReportListing();
BindReport(ConfigurationManager.AppSettings["reportlocation"].ToString() + 
myListing.GetReportFileName(Session["Report"].ToString()));
}
}

protected void btnBuild_Click(object sender, EventArgs e)
{
CrystalReportViewer1.ParameterFieldInfo.Clear();
DateTime startDate = DateTime.Parse(Session["FromDate"].ToString());
DateTime endDate = DateTime.Parse(Session["ToDate"].ToString());

ParameterFields paramFields = new ParameterFields();
ParameterField crStartDate = new ParameterField();
ParameterField crEndDate = new ParameterField();
crStartDate.Name = "@StartDate";
crEndDate.Name = "@EndDate";
ParameterDiscreteValue dcrStartDate = new ParameterDiscreteValue();
ParameterDiscreteValue dcrEndDate = new ParameterDiscreteValue();
dcrStartDate.Value = startDate;
dcrEndDate.Value = endDate;
crStartDate.CurrentValues.Add(dcrStartDate);
crEndDate.CurrentValues.Add(dcrEndDate);
paramFields.Add(crStartDate);
paramFields.Add(crEndDate);

ReportListing myListing = new ReportListing();
BindReport(ConfigurationManager.AppSettings["reportlocation"].ToString() + 
myListing.GetReportFileName(Session["Report"].ToString()));
CrystalReportViewer1.ParameterFieldInfo = paramFields;
ViewState["ParametersShown"] = "True";
ViewState["ReportName"] = Session["Report"].ToString();
}
private void BindReport(string FilePath)
{
ReportDocument Report = new ReportDocument();
Report.Load(FilePath);
SetTableLocation(Report.Database.Tables);
CrystalReportViewer1.ReportSource = Report;
}
private void SetTableLocation(Tables tables)
{
ConnectionInfo connectionInfo = new ConnectionInfo();
connectionInfo.ServerName = ConfigurationManager.AppSettings["ReportDBServerName"].ToString();
connectionInfo.DatabaseName = ConfigurationManager.AppSettings["ReportDBDBName"].ToString();
connectionInfo.UserID = ConfigurationManager.AppSettings["ReportDBUserID"].ToString();
connectionInfo.Password = ConfigurationManager.AppSettings["ReportDBPassword"].ToString();
foreach (CrystalDecisions.CrystalReports.Engine.Table table in tables)
{
TableLogOnInfo tableLogOnInfo = table.LogOnInfo;
tableLogOnInfo.ConnectionInfo = connectionInfo;
table.ApplyLogOnInfo(tableLogOnInfo);
}
}
}


如上所述,从本地计算机运行可以正常工作.仅当发布到生产服务器时,它才会要求登录详细信息.登录详细信息存储在web.config文件中,并且正确.
请帮忙!
谢谢

[从答案中移出]

是的,启用了匿名访问,并且对文件夹具有适当的权限.它要求的凭据是数据库凭据.在开发服务器上工作时,它指向同一数据库,但是自发布到生产以来,它要求提供数据库登录凭据.同样(有点奇怪),当我要求提供凭据时,它也不允许我输入数据库名称.
如果我从开发机上运行完全相同的应用程序,它将正确传递数据库参数和登录信息,从而正确绕过数据库登录屏幕.我看不到这种行为的任何正当理由.

解决方案

我已经解决了.问题在于它使用了未安装在生产服务器上的SQL Native Client.我已经安装了此程序,并且一切正常.


As detailed above, running from a local machine it works fine. It is only when published to production server it asks for login details. Login details are stored in the web.config file and are correct.
Please help!
Thanks

[Moved from Answers]

Yes, Anonymous access is enabled and it has suitable permissions on the folder. The credentials it is asking for is the database credentials. When working on development server it was pointing at the same database, but since publishing to production, it asks for database login credentials. Also (rather weirdly), it won''t let me type in database name when asked for the credentials either.
If I run exactly the same application from my development machine it correctly passes the DB parameters and login info, thus bypassing the DB login screen correctly. I can see no legitimate reasoning for this behavior.

Solution

I have resolved this. Problem is that it uses the SQL Native Client, which is not installed on the production server. I have since installed this and all is working.

推荐答案

您是否已在身份验证方法下为IIS中的该站点/目录启用了匿名访问?

我不认为Crystal Report要求用户提供登录凭据,因为它的UserID和密码用于访问数据库而不是页面
Have you enabled anonymous access under authentication method for that site / directory in IIS?

I don''t think crystal report asks for login credentials as its UserID and Password is for accessing database not page


好,您已经弄清楚了;)
这样的问题在生产服务器中确实很难指出.:thumbsup:
Great that you figured it out ;)
such issues are really very hard to point in production servers.:thumbsup:


受保护的空白Page_Load(object sender,EventArgs e)
{
ReportDocument crystalReport = new ReportDocument();
crystalReport.Load(Server.MapPath("CrystalReportByAgents.rpt")));
crystalReport.SetDatabaseLogon("LoginId","Password",@"SYSTEM \ SQLEXPRESS","databaseName");

CrystalReportViewer1.ReportSource = crystalReport;
}
protected void Page_Load(object sender, EventArgs e)
{
ReportDocument crystalReport = new ReportDocument();
crystalReport.Load(Server.MapPath("CrystalReportByAgents.rpt"));
crystalReport.SetDatabaseLogon("LoginId", "Password", @"SYSTEM\SQLEXPRESS", "databaseName");

CrystalReportViewer1.ReportSource = crystalReport;
}


这篇关于Crystal Reports登录无法在生产中使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆