Link to home
Start Free TrialLog in
Avatar of Adi
AdiFlag for Israel

asked on

Why Crystal Report Opening is failed in Access 2007 application?

I have developed a component in VB.NET Visual Studio 2013.
This Class Library contains Crystal Report.
While testing this Class Library in Win Form application I have get error message:
CrystalDecisions.CrystalReports.Engine.DataSourceException: Failed to load database information.
Error in File temp_e2ac33fe-6dc0-4fcf-b1f3-997c8509c545 {97C9C8CE-1590-420A-8BF7-8EA56100CEA9}.rpt:
Failed to load database information. ---> System.Runtime.InteropServices.COMException: Failed to load database information.
Error in File temp_e2ac33fe-6dc0-4fcf-b1f3-997c8509c545 {97C9C8CE-1590-420A-8BF7-8EA56100CEA9}.rpt:
Failed to load database information.
   at CrystalDecisions.ReportAppServer.Controllers.DatabaseControllerClass.ReplaceConnection(Object oldConnection, Object newConnection, Object parameterFields, Object crDBOptionUseDefault)
   at CrystalDecisions.CrystalReports.Engine.Table.SetDataSource(Object val, Type type)
   at CrystalDecisions.CrystalReports.Engine.ReportDocument.SetDataSourceInternal(Object val, Type type)
   --- End of inner exception stack trace ---
   at CrystalDecisions.ReportAppServer.ConvertDotNetToErom.ThrowDotNetException(Exception e)
   at CrystalDecisions.CrystalReports.Engine.ReportDocument.SetDataSourceInternal(Object val, Type type)
   at CrystalDecisions.CrystalReports.Engine.ReportDocument.SetDataSource(DataSet dataSet)
   at FedexManager.frm_shpDailyManifest.ShowManifest(DateTime FromDate, DateTime ToDate)
   at FedexManager.clsFedexManager.GetDailyManifest(Int32 iManifestId)

After adding to app.config file an attribute  useLegacyV2RuntimeActivationPolicy="true" to startup tag this problem was fixed.

When I use this Class Library in Access application I have getting a similar error message:
CrystalDecisions.CrystalReports.Engine.DataSourceException: Failed to load database information.
Error in File temp_e0f83f2f-078a-432e-90af-8a6049c259dd {86154599-8E93-4293-BD42-3802A288D9B7}.rpt:
Failed to load database information. ---> System.Runtime.InteropServices.COMException: Failed to load database information.
Error in File temp_e0f83f2f-078a-432e-90af-8a6049c259dd {86154599-8E93-4293-BD42-3802A288D9B7}.rpt:
Failed to load database information.
   at CrystalDecisions.ReportAppServer.Controllers.DatabaseControllerClass.ReplaceConnection(Object oldConnection, Object newConnection, Object parameterFields, Object crDBOptionUseDefault)
   at CrystalDecisions.CrystalReports.Engine.Table.SetDataSource(Object val, Type type)
   at CrystalDecisions.CrystalReports.Engine.ReportDocument.SetDataSourceInternal(Object val, Type type)
   --- End of inner exception stack trace ---
   at Microsoft.VisualBasic.CompilerServices.Symbols.Container.InvokeMethod(Method TargetProcedure, Object[] Arguments, Boolean[] CopyBack, BindingFlags Flags)
   at Microsoft.VisualBasic.CompilerServices.NewLateBinding.CallMethod(Container BaseReference, String MethodName, Object[] Arguments, String[] ArgumentNames, Type[] TypeArguments, Boolean[] CopyBack, BindingFlags InvocationFlags, Boolean ReportErrors, ResolutionFailure& Failure)
   at Microsoft.VisualBasic.CompilerServices.NewLateBinding.ObjectLateCall(Object Instance, Type Type, String MemberName, Object[] Arguments, String[] ArgumentNames, Type[] TypeArguments, Boolean[] CopyBack, Boolean IgnoreReturn)
   at Microsoft.VisualBasic.CompilerServices.NewLateBinding.LateCall(Object Instance, Type Type, String MemberName, Object[] Arguments, String[] ArgumentNames, Type[] TypeArguments, Boolean[] CopyBack, Boolean IgnoreReturn)
   at Techsign.Invoices.cls_invcShipInvoice.GetShipInvoice(Int32 iInvoiceId, String ConnectionString, Int32 VersionType, enInvoiceType InvoiceType, Int32 LanguagePackId).

What I should to do to resolve this problem?
Avatar of Mike McCracken
Mike McCracken

What version of Crystal Reports?
Only versions before CR 2008 have an SDK that can be used with applications like MS Access.

Are you using an mdb or accdb?
Most versions of Crystal cannot use an aacdb as the data source.

mlmcc
Avatar of Adi

ASKER

1. I'm using last version of Crystal Report for Visual Studio 2013 (v. 13.0.9.1312).
The report is developed in Visual Studio 2013 as Class Library.

2. I'm using accdb (accde) as GUI.
Data is stored in SQL Server.
Can you open reports in the VS IDE from the database?

Did you install the MS Office ODBC connections for Office 20xx?

I don't know about the licensing for that version of Crystal and VS but it may be you can't call it from another application.

mlmcc
Avatar of Adi

ASKER

I can open reports in the VS IDE.
More of that I have created Win Form application for testing this Class Library, and Report is opened correctly when I run executable Test application.
It's working when app.config contains useLegacyV2RuntimeActivationPolicy="true" attribute
.......
<startup useLegacyV2RuntimeActivationPolicy="true"><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup>

Without useLegacyV2RuntimeActivationPolicy="true" attribute the problem exists in WinForm Test application also.

Our Access application don't need ODBC connection: a connection string is stored in Windows Registry.

Class Library object has connection string property.

The problem exists on the development computer. My test application is another application also. It's working without any license.
Applications developed in VS using the VS version of Crystal do NOT have a licensing issue.  It is the calling the reports from MS Access that I question.

How are you connecting the report to the database?
Crystal maintains its own connection to the database so even when you are in MS Access the report needs its own connection.  How are you setting the database connection to the report from the Access application?  Is it handled in the class you built?

mlmcc
Avatar of Adi

ASKER

Hi mlmcc,
The report hasn't any own connection to the database.
I'm using dataset as datasource for the report.
What code are you using to pass the recordset to the report?

Your error indicates the report is trying to open the database.

mlmcc
Avatar of Adi

ASKER

Hi mlmcc,

This is a code:

Public Sub GetShipInvoice(ByVal iQuoteId As Integer, ByVal ConnectionString As String, ByVal VersionType As Integer)
        Dim dsShipInvoice As dsShipInvoice = New dsShipInvoice
        Dim rw As frm_rptReportViewer = New frm_rptReportViewer
        Dim rpt As rpt_shpInvoice = New rpt_shpInvoice

        Try
            Dim m_iShipToId As Integer = Data.DLookup(ConnectionString, "ShipID", "tbl_qteQuotes", "QuoteID=" & iQuoteId)
            Dim m_iBillToId As Integer = Data.DLookup(ConnectionString, "ContactID", "tbl_qteQuotes", "QuoteID=" & iQuoteId)
            Dim m_strCountry As String = Data.DLookup(ConnectionString, "Country", "tbl_cntContacts", "SerNum=" & m_iShipToId)

            Try
                GetCompanyInfoDataTable(ConnectionString, dsShipInvoice.tblIcons)
                Data.FillDataTable(ConnectionString, "Select * from udf_qte_shpInvoiceDetails(" & iQuoteId & ")", dsShipInvoice.udf_qte_shpInvoiceDetails)
                Data.FillDataTable(ConnectionString, "Select * from tbl_qteInvoice WHERE QuoteID=" & iQuoteId, dsShipInvoice.tbl_qteInvoice)
                Data.FillDataTable(ConnectionString, "Select * from tbl_qteQuotes WHERE QuoteID=" & iQuoteId, dsShipInvoice.tbl_qteQuotes)

                Data.FillDataTable(ConnectionString, "SELECT TOP 1 IT.* FROM tbl_qteQuotes Q INNER JOIN tbl_qteIncoTerms IT ON Q.IncoTerms = IT.TermType WHERE Q.QuoteID=" & iQuoteId, dsShipInvoice.tbl_qteIncoTerms)
                Data.FillDataTable(ConnectionString, "SELECT P.* FROM tblPayment P INNER JOIN tbl_qteQuotes Q ON P.PayMent = Q.PayMent WHERE Q.QuoteID=" & iQuoteId, dsShipInvoice.tblPayment)

                GetContact(ConnectionString, m_iShipToId, dsShipInvoice.tbl_cntShipTo)
                GetContact(ConnectionString, m_iBillToId, dsShipInvoice.tbl_cntContacts)
            Catch ex As Exception
                Exceptions.PrintErrorToLog("GetShipInvoice-1", ex.ToString)
            End Try

            rpt.SetDataSource(dsShipInvoice)

            Dim objDeclaration As CrystalDecisions.CrystalReports.Engine.FormulaFieldDefinition = rpt.DataDefinition.FormulaFields("txtDeclaration")
            objDeclaration.Text = "'" + GetDeclaration(m_strCountry).Replace(vbCrLf, "' + chr(10) + '") + "'"
            objDeclaration = Nothing

            Dim objRefNo As CrystalDecisions.CrystalReports.Engine.TextObject = rpt.Section1.ReportObjects.Item("txtRefNo")
            objRefNo.Text = GetRefNo(ConnectionString, iQuoteId, VersionType)
            objRefNo = Nothing

            If VersionType <> 0 Then
                Dim objStamp As CrystalDecisions.CrystalReports.Engine.PictureObject = rpt.Section10.ReportObjects("picTechSignStamp")
                objStamp.Width = 0
                objStamp.Height = 0
                objStamp = Nothing
            End If

            Try
                Dim bEUR As Boolean = Misc.nz(Data.FirstRow(ConnectionString, "EXEC dbo.sp_cntIsEUR '" & m_strCountry & "'")("EUR"), False)
                If Not bEUR Then
                    Dim objStamp As CrystalDecisions.CrystalReports.Engine.PictureObject = rpt.Section4.ReportObjects("picEUR1Stamp")
                    objStamp.Width = 0
                    objStamp.Height = 0
                    objStamp = Nothing
                End If
            Catch ex As Exception
                Exceptions.PrintErrorToLog("GetShipInvoice", "Missing Countries Table: " & ex.ToString)
                Dim objStamp As CrystalDecisions.CrystalReports.Engine.PictureObject = rpt.Section4.ReportObjects("picEUR1Stamp")
                objStamp.Width = 0
                objStamp.Height = 0
                objStamp = Nothing
            End Try

            Try
                With rw
                   .crvMain.ToolPanelView = CrystalDecisions.Windows.Forms.ToolPanelViewType.None
                   .crvMain.ReportSource = rpt
                    .ShowDialog()
                End With
            Catch ex As Exception
                MsgBox(ex.ToString)
                Exceptions.PrintErrorToLog("GetShipInvoice-2", ex.ToString)
            End Try

        Catch ex As Exception
            Exceptions.PrintErrorToLog("GetShipInvoice-3", ex.ToString)
        Finally
            rpt.Dispose()
            rpt = Nothing
            rw.Dispose()
            rw = Nothing
            dsShipInvoice.Dispose()
            dsShipInvoice = Nothing
        End Try
    End Sub

Thanks
Was the report originally written using a database connection as the data source?

mlmcc
Avatar of Adi

ASKER

No.
The dataset item was created in the VS project on the base of tables and udf's of a real database.
The report was created with this dataset as data source.

Thanks
ASKER CERTIFIED SOLUTION
Avatar of Adi
Adi
Flag of Israel image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Adi

ASKER

I have find the solution with the help of SAP Community Network expert Ludek Uher.