水晶报表:CrystalDecisions.CrystalReports.Engine.LogOnException: 登录失败
我建立了一个报表文件c:\test.rpt,在webform中加了一个CrystalReportViewer,并设置其ReportSource为"c:\\test.rpt"(设计时在vs.net ide中可以预览报表),在webform的Page_Load中对CrystalReportViewer进行邦定this.CrystalReportViewer1.DataBind();
这样运行程序,出现登陆失败的错误(使用sql2000或access数据库,数据库有密码,均出现登陆失败的错误,取消数据库密码能正常运行),详细错误如下:
“/WebApplication1”应用程序中的服务器错误。
--------------------------------------------------------------------------------
登录失败。
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。
异常详细信息: CrystalDecisions.CrystalReports.Engine.LogOnException: 登录失败。
源错误:
执行当前 Web 请求期间生成了未处理的异常。可以使用下面的异常堆栈跟踪信息确定有关异常原因和发生位置的信息。
堆栈跟踪:
[LogOnException: 登录失败。]
.K(String
, EngineExceptionErrorID )
.F(Int16 , Int32 )
.E(Int16 )
CrystalDecisions.CrystalReports.Engine.FormatEngine.GetPage(PageRequestContext reqContext)
CrystalDecisions.ReportSource.LocalReportSourceBase.GetPage(PageRequestContext pageReqContext)
CrystalDecisions.Web.ReportAgent.v(Boolean `)
CrystalDecisions.Web.CrystalReportViewer.OnPreRender(EventArgs e)
System.Web.UI.Control.PreRenderRecursiveInternal()
System.Web.UI.Control.PreRenderRecursiveInternal()
System.Web.UI.Control.PreRenderRecursiveInternal()
System.Web.UI.Page.ProcessRequestMain()
--------------------------------------------------------------------------------
版本信息: Microsoft .NET 框架版本:1.0.3705.0; ASP.NET 版本:1.0.3705.0
望指点,感激不尽!
问题点数:100、回复次数:6Top
1 楼blucecat(广种薄收)回复于 2002-05-28 22:01:48 得分 0
?Top
2 楼calfly(东方之猪)回复于 2002-05-29 08:29:53 得分 60
[转]
在使用Crystal Report制作报表时,碰到出现Database Login数据库登录窗口,是由于报表访问的后台数据库MS SQL Server需要提供登录信息。一般情况下,如果后台数据库需要认证(如MS SQL Server),则应提供登录信息。如下提供一段示例代码供您参考:
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared
……
Dim crReport As New CrystalReport1()
Dim repDB As Database = crReport.Database
Dim repTbls As Tables = repDB.Tables
Dim repTbl As Table
repTbl = repTbls(0)
Dim logonInfo As TableLogOnInfo = repTbl.LogOnInfo
logonInfo.ConnectionInfo.Password = "password"
repTbl.ApplyLogOnInfo(logonInfo)
CrystalReportViewer1.ReportSource = crReport
请根据您系统的实际情况,将提供的代码进行修改。希望以上答复给您带来帮助。Top
3 楼lijiajia(大帅哥)回复于 2002-05-29 09:20:07 得分 20
你在做rpt报表时,连接数据库时就应该输入你的数据库服务器名和登录信息。这样你后来生成报表就不会出错!
我是一直这样做的,没有出现你说的错误!Top
4 楼calfly(东方之猪)回复于 2002-05-29 11:21:28 得分 0
我正在做这方面的程序。
以下是我的code,我把报表绑定的工作写在类ReportDB里。
public class ReportDB
{
// 创建DataSet
private DataSet SetDataSet(string strSQL,string strTable)
{
// Create SqlConnection instance
SqlConnection myConnection = new SqlConnection();
myConnection.ConnectionString = "server=localhost;uid=sa;pwd=;database=XXX";
// Create SqlCommand instance
SqlCommand myCommand = new SqlCommand();
myCommand.Connection = myConnection;
myCommand.CommandText = strSQL;
myCommand.CommandType = CommandType.Text;
// Create SqlDataAdapter instance
SqlDataAdapter myDA = new SqlDataAdapter();
myDA.SelectCommand = myCommand;
// Set DataSet by SqlDataAdapter
DataSet myDS = new DataSet();
myDA.Fill(myDS,strTable);
// Close data Connection
myConnection.Close();
//return myDS.Tables["PersonalBroker"].DataSet;
return myDS;
}
// ***************************************************************
// [Author] calfly@263.net
// [Date] 05-28-2002
// [Note] 将报表绑定到CrystalReportViewer,此报表的数据源由执行strSQL语句生成
// [Input] strSQL:数据库查询语句,strTable:表名,strReportName:报表文件名,oCrv:CrystalReportViewer名
// [Output]
// ***************************************************************
public void ReportBind(string strSQL,string strTable,string strReportFileName,CrystalReportViewer oCrv)
{
ReportDocument oRpt = new ReportDocument();
Page oPage = new Page();
oRpt.Load(oPage.Server.MapPath(strReportFileName));
oRpt.SetDataSource(SetDataSet(strSQL,strTable));
oCrv.pa
oCrv.ReportSource = oRpt;
}
}
在有CrystalReportViewer的web form里通过调用以上类生成报表:
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
strTable = "PersonalBroker";
strSQL = "SELECT PName,BrokerNo,StudentNo FROM PersonalBroker WHERE Polity ='共产党员'";
strReportFileName = "PersonalCertificateEnregister.rpt";
ReportDB myReportDB = new ReportDB();
myReportDB.ReportBind(strSQL,strTable,strReportFileName,CrystalReportViewer1);
}
---over-------Top
5 楼blucecat(广种薄收)回复于 2002-05-29 13:32:32 得分 0
这些方法我都用过,没解决
哎!还是我慢慢摸索吧Top
6 楼lijiajia(大帅哥)回复于 2002-06-04 21:16:31 得分 0
真的可以解决,兄弟给分撒!Top
7 楼icyer()回复于 2002-06-05 09:12:47 得分 20
There is a article:
http://www.dotnet247.com/247reference/msgs/15/79339.aspxTop




