使用Crystal Reports的数据库登录错误

时间:2013-08-01 13:07:34

标签: vb.net crystal-reports

我有以下一些简单的代码,基于教程应该可以工作:

Try
   Dim report As CustomerStatus = New CustomerStatus
   report.Load("Reports/CustomerStatus.rpt")

   report.SetParameterValue("id_customer", 130)
   report.SetDatabaseLogon("root", "", "localhost", "aerospace")

   report.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, "c:\customer_status.pdf")

Catch ex As Exception
   MessageBox.Show(ex.Message)
End Try

无论我是直接连接(SetDatabaseLogon)还是使用报表编译中指定的详细信息,我都会收到此错误:

"Database Logon Failed."

我也尝试连接到本地和生产服务器,但都不起作用。

我正在使用Crystal Reports for Visual Studio 2012 Professional。

2 个答案:

答案 0 :(得分:0)

使用“localhost”时,Crystal引擎有时会出现问题,请尝试使用实际的服务器名称

答案 1 :(得分:0)

我遇到了类似的问题,其中只有某些报告会因此错误而失败但仅在第一次运行时 - 例如在应用程序池刚刚启动之后。后续尝试运行报告没有错误。一旦应用程序池w3wp.exe进程被终止并重新启动,就会发生错误。在我的特定情况下,我运行CR2008(第12版),数据库是位于同一服务器上的SQL Server 2008 R2,运行报告的asp.net应用程序。 ap池已启用32位应用程序。 解决方案是在SQL Server配置管理器中启用TCPIP连接。默认情况下,仅启用命名管道。 启用TCPIP并重新启动SQL Server后,错误就消失了。