cancel
Showing results for 
Search instead for 
Did you mean: 

Database logon failed when exporting Crystal Report to PDF

0 Kudos

I have converted a ASP.NET 1.0 app to 4.0.  It is a simple app with only 3 pages and 4 reports.  For the most part the conversion went well and on both my development machine and the production machine I can run it, navigate between the pages, retrieve and update data from a SQL Server 2008 R2 database.  On the development machine I can also create Crystal Reports which are then exported to PDF.  On the production machine however when I try to do this I get this message:

Server Error in '/EslCalls' Application.


Database logon failed.

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: Database logon
failed.

Source Error:

An unhandled exception was generated during the execution of the
current web request. Information regarding the origin and location of the
exception can be identified using the exception stack trace below.


Stack Trace:

[COMException (0x8004100f): Database logon failed.] CrystalDecisions.ReportAppServer.Controllers.ReportSourceClass.Export(ExportOptions pExportOptions, RequestContext pRequestContext) +0 CrystalDecisions.ReportSource.EromReportSourceBase.ExportToStream(ExportRequestContext reqContext) +362  [LogOnException: Database logon failed.] CrystalDecisions.ReportAppServer.ConvertDotNetToErom.ThrowDotNetException(Exception e) +909 CrystalDecisions.ReportSource.EromReportSourceBase.ExportToStream(ExportRequestContext reqContext) +471 CrystalDecisions.CrystalReports.Engine.FormatEngine.ExportToStream(ExportRequestContext reqContext) +772 CrystalDecisions.CrystalReports.Engine.FormatEngine.Export(ExportRequestContext reqContext) +185 CrystalDecisions.CrystalReports.Engine.FormatEngine.Export() +115 CrystalDecisions.CrystalReports.Engine.ReportDocument.Export() +80 EslCalls.Reports.MakePDFfile(ReportDocument crpt, String ReportName) in C:\WebApps\EslCalls\Reports.aspx.vb:158 EslCalls.Reports.btnSubmit_Click(Object sender, EventArgs e) in C:\WebApps\EslCalls\Reports.aspx.vb:97 System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +155 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3804 


Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET
Version:4.0.30319.34209

On my development machine:

     Windows 7

     IIS 7

     Visual Studio 2010

     Crystal Reports for Visual Studio 2010

     The reports had been developed in Crystal XI but they were imported in to VS 2010 converted and saved

     The app runs under a application pool I created that uses a network Windows account that has all the necessary permission on the SQL Server      objects.

     In the web.config file identity impersonate is set to true.

On the production machine:

     Windows Server 2012 R2

     IIS 8

     SAP Crystal Reports runtime engine for. NET Framework (64-bit) 13.0.10.1385

    The app runs under a application pool I created that uses the same Windows account as on my development machine

     In the web.config file identity impersonate is set to true.

IIS and application are on one server and SQL Server is on another. The server that IIS is on is named Intranet02 and the Intranet02$ account has all the necessary permissions on the database objects.

The pertinent code:

Dim crpt As New ReportDocument()

crpt = New rptCategory()

ReportName = "Category"

MakeCrParameter(txtStartDate.Text, "@StartDate", crpt)

MakeCrParameter(txtEndDate.Text, "@EndDate", crpt)

FileName = MakePDFfile(crpt, ReportName)

Private Function MakePDFfile(ByVal crpt As ReportDocument, ByVal ReportName As String) As String

     Dim TodayFile As String = Month(Now) & Day(Now) & Year(Now)

     Dim FileName As String = ReportName & " " & Now.Month & "-" & Now.Day & "-" & Now.Year & "-" & Now.Second & ".pdf"

     Dim dfdo As New CrystalDecisions.Shared.DiskFileDestinationOptions()

     dfdo.DiskFileName = "C:\WebApps\EslCalls\Reports\" & FileName

     With crpt

          ExportOptions.ExportDestinationType = ExportDestinationType.DiskFile

          .ExportOptions.ExportFormatType = ExportFormatType.PortableDocFormat

          .ExportOptions.DestinationOptions = dfdo

          Export()

          Close()

          .Dispose()

     End With

     GC.Collect()

     GC.WaitForPendingFinalizers()

     MakePDFfile = FileName

     'Open a new window linked to the PDF file containing the report.  The window is resizable.

     Dim Script As String = "<Script language='javascript'> win=window.open('/EslCalls/Reports/" + FileName + "','Reports','width=800,height=500,resizable=1')</script>"

     Page.ClientScript.RegisterStartupScript(Me.GetType(), "Session Timed Out", Script, False)

     'Clear the form after the report has been created

     Clear() End Function

The error occurs at the line

          Export()

Any suggestions would be greatly appreciated.

I have a report that doesn't connect to a database and it opens on the production machine.  It seems like it must be a permissions issue but I don't know what it would be as the app should be running under the same account on both my development and my production machine and the reports open on my development machine.

I was thinking perhaps on the server the app was running under a different identity then I expected so I put Dim username As String = System.Security.Principal.WindowsIdentity.GetCurrent().Name Response.Write("User = " & username) right before the code that generates the report.  On both the production and development machines it shows the correct user account.

Accepted Solutions (1)

Accepted Solutions (1)

former_member183750
Active Contributor
0 Kudos

Hi Les

Couple of things to check off:

If the connection is via ODBC, make sure you are using a 64 bit ODBC datasource.

This being MS SQL the following client installs are important:

MS SQL 2005 - OLE DB Provider
MS SQL 2008 - SQL Native 10
MS SQL 2012 - SQL Native 11
MS SQL 2013 - SQL Native 11


For ODBC then use:

MS SQL 2005 - SQL Native
MS SQL 2008 - SQL Native 10
MS SQL 2012 - SQL Native 11
MS SQL 2013 - SQL Native 11

Other than that, in your code I do not see any APIs for establishing a database connection(?).

- Ludek

Senior Support Engineer AGS Product Support, Global Support Center Canada

Follow us on Twitter

0 Kudos

Hello Ludek,

Thanks for getting back to me on this.

The database connection is a OLE DB (ADO) connection set within the report.  I'm sure the connection is correct as I can verify it in Visual Studio and can open the report it VS and through the app on my development machine.

0 Kudos

I'm trying to create a new Datasource Location for one of the reports hard coding in a User ID and password instead of using Integrated Security but when I click on Finish I get this message:

Login failed.

Details:ADO Error Code: 0x80040e4d

Source: Microsoft OLE DB Provider for SQL Server

Description:Login failed for user 'HRanon'.

SQL State: 42000

Native Error: 18456 [Database Vendor Code 18456]

This happens even if I use my user name and password which has administrative permissions on both server.

Former Member
0 Kudos

Hi,

I hope the problem might be:

The only thing is, Need to set Database credentials at runtime for the Crystal Report to work fine.

crpt.SetDatabaseLogon("user", "password", "server", "database")



Thanks,

DJ

0 Kudos


Hello DJ,

Thanks for you response.  That worked however I'd rather not have the username and password exposed in the code.  Before the coversion and in other non-converted apps I'm able to use Integrated Security, do you have any idea why I can't any longer?

Thanks,

Les

Former Member
0 Kudos

Hi,

It was failing because the SQL Native Client was not installed on the production server.

Please check the  file "sqlncli.dll" exist in server or not?  .. not sure this file or some other dll

Thanks,

DJ

former_member183750
Active Contributor
0 Kudos

Hi Les

Integrated security works as it always has. The error "Database Vendor Code 18456" is coming directly from the database client so check the db documentation for details on that. Googling the error and quickly scanning some of the hits I still believe you do not have the correct client installed on that computer though...

- Ludek

0 Kudos

Hello Ludek,

One of our network engineers is going to install SQL Native 10 on the server.  I'll let you know the result.

0 Kudos

Hello Ludek,

Installing the client did the trick.  Thank you very much for your help and thanks to DJ as well.

Answers (0)