自动登录数据库CrystalReport [英] Auto logon database CrystalReport

查看:119
本文介绍了自动登录数据库CrystalReport的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,

我在使用Crystal Report Viewer和Visual Studio进行自动登录时遇到了问题.

以下代码用于即时登录和传递parm值,这些都在Page_Load中:

ello,

I have been having issues with auto logon for crystal report viewer and visual studio.

The following code is im using to auto logon and pass on parm values and this is all inside Page_Load:

pono.Text = Request.QueryString["PONU"];
mrrr.Text = Request.QueryString["MRNU"];


//login so users wont have to enter user/pass all the time
ReportDocument cryRpt = new ReportDocument();
TableLogOnInfos crtableLogoninfos = new TableLogOnInfos();
TableLogOnInfo crtableLogoninfo = new TableLogOnInfo();
ConnectionInfo crConnectionInfo = new ConnectionInfo();
Tables CrTables;

cryRpt.Load("~/reports/MatRecReport-new.rpt");

crConnectionInfo.ServerName = "e40";
crConnectionInfo.DatabaseName = "";
crConnectionInfo.UserID = "user";
crConnectionInfo.Password = "pss";

CrTables = cryRpt.Database.Tables;
foreach (CrystalDecisions.CrystalReports.Engine.Table CrTable in CrTables)
{
    crtableLogoninfo = CrTable.LogOnInfo;
    crtableLogoninfo.ConnectionInfo = crConnectionInfo;
    CrTable.ApplyLogOnInfo(crtableLogoninfo);
}



这是我得到的错误:



And this is the error i get:

Server Error in '/' Application.

Unsupported Operation. A document processed by the JRC engine cannot be opened in the C++ stack. 
  Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

 Exception Details: System.Runtime.InteropServices.COMException: Unsupported Operation. A document processed by the JRC engine cannot be opened in the C++ stack.

Line: cryRpt.Load("~/reports/MatRecReport-new.rpt");





How can i load the report thats in the project folder itself?

推荐答案

从您所显示的结果来看,问题将归结于如何解决路径.
例如,〜字符是指Web服务器上应用程序的主目录.
From what you have shown the problem will be due to how your path is being resolved.
The ~ character refers to the home directory of the application on your web server, for instance;
http://localhost:1234



要确认您的路径是否有效,您只需在Web浏览器中输入文件的路径(当然,该解决方案就会运行),如下所示;



To confirm if your path is valid you can just enter the path to the file in your web browser (with the solution running of course) as follows;

http://localhost:1234/reports/MatRecReport-new.rpt


如果提示您保存或打开文件,则您的路径正确.

正确的路径后,您将需要按以下方式使用Server.MapPath;


If you are prompted to save or open the file your path is correct.

Once your path is correct, you will need to use Server.MapPath as follows;

cryRpt.Load(Server.MapPath("~/reports/MatRecReport-new.rpt"));



亲切的问候



Kind Regards


这篇关于自动登录数据库CrystalReport的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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