Skip to Content
0

Crystal Reports Database Logon Failed

Apr 28, 2017 at 04:17 PM

94

avatar image

We are seeing a problem in production that we cannot reproduce in our development environment. The error is intermittent, only some users receive the error. The error is

Message :Database logon failed.
Source :Analysis Server
Stack Trace : at CrystalDecisions.ReportAppServer.Controllers.ReportSourceClass.Export(ExportOptions pExportOptions, RequestContext pRequestContext)
at CrystalDecisions.ReportSource.EromReportSourceBase.ExportToStream(ExportRequestContext reqContext)

In my mind the report should not be connection to the database at all. The code is below

Dim v_server_name As String = ConfigurationManager.AppSettings("ReportsServer")

Dim v_db_name As String = ConfigurationManager.AppSettings("ReportsDB")

Dim v_user_name As String = ConfigurationManager.AppSettings("ReportsUser")

Dim v_pass As String = ConfigurationManager.AppSettings("ReportsPass")

'create crystal report in memory

crReportDocument = New CrystalDecisions.CrystalReports.Engine.ReportDocument()

Dim fullName As String = getReportDir() & "\" & reportname crReportDocument.FileName = fullName

crReportDocument.DataSourceConnections(0).SetConnection(v_server_name, v_db_name, v_user_name, v_pass) crReportDocument.Load(crReportDocument.FileName)

For x = 0 To crReportDocument.Subreports.Count - 1 crReportDocument.Subreports(x).DataSourceConnections.Clear()

Next

Dim ds2, ds3 As Data.DataSet

sql = " xxx " ds2 = util_mup.Get_RecSet(sql) crReportDocument.OpenSubreport("certif_of_performance_body.rpt") crReportDocument.Subreports("certif_of_performance_body.rpt").SetDataSource(ds2.Tables(0))

ds2.Dispose()

'FOOT

sql = " ### " ds3 = util_mup.Get_RecSet(sql) crReportDocument.OpenSubreport("certif_of_performance_final_footer.rpt") crReportDocument.Subreports("certif_of_performance_final_footer.rpt").SetDataSource(ds3.Tables(0)) ds3.Dispose()

Return exportPDF()

Private Function exportPDF() As Byte() Dim crExportOptions As CrystalDecisions.Shared.ExportOptions Dim req As CrystalDecisions.Shared.ExportRequestContext = New CrystalDecisions.Shared.ExportRequestContext crExportOptions = crReportDocument.ExportOptions With crExportOptions .FormatOptions = New CrystalDecisions.Shared.PdfRtfWordFormatOptions .ExportFormatType = CrystalDecisions.Shared.ExportFormatType.PortableDocFormat End With req.ExportInfo = crExportOptions Dim st As System.IO.Stream = crReportDocument.FormatEngine.ExportToStream(req) Dim pdfdata(st.Length) As Byte st.Read(pdfdata, 0, st.Length) st.Close() st.Dispose() Return pdfdata

End Function

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Don Williams
Apr 28, 2017 at 04:26 PM
0

Hi Patrick,

When you export unless the report has saved data it is hitting the database.

When you get errors from the database CR is simply passing the message through it to you.

Things to check is does that user have full permissions to access the tables used in the report? CR fully supports DB security, depending on how you have the app configured.

DB Servers now use Connection Pooling, so when CR connects the connection is cached on the Server waiting for someone else to request a connection. CR does not support this at the moment, it will create a new connection when a new report or subreport is used.

You can disable that function on the Server, check your Server help file for more info and if it's possible.

Run SQL Profiler on the DB server and see what it is saying when the error happens.

Check your report, if there are ANY? error in formula or other parts fix them, unlike CR Designer when creating reports you can save bad formula and other parts, because it is a design tool, but in code CR runtime expects the report to be 100%. Delete any formulae not used, tables and anything else not required to run the report. You can delete parts in code also if need be.

See the download page, there is a How To.. Parameter test app that has a lot of extra feature in the drop downlist box that can check the variosu parts of the report.

Don

Show 1 Share
10 |10000 characters needed characters left characters exceeded

Are you saying that crystal reports does not use the data that is passed to the report when we export the report?

the application is a web application so all users use the same connection string. What could cause the database login error for some users while others have no issue?

What would crystal reports be using to connect to the database in this case? In trying to reproduce the issue in our environment we set the user name and password to invalid values and we have no issue. The report is exported using the data we passed to it.

0