Skip to Content
avatar image
Former Member

How to connect Crystal Reports for VS2015 to Access DB using 64 bit application

I have a small DLL built in C# which provides an interface to a C++ application to use the Crystal Viewer, print reports etc. This application works well with 32 bit applications. I recently rebuilt this DLL as 64 bit (target platform 64 bit) to work with a 64 bit application. When trying to preview a report with the 64 bit DLL, the viewer comes up but gives an error of "Login Failed" and won't show the report. If I simply hit refresh on the viewer toolbar, it shows the report. (I've listed the code below)

The RPT file is currently configured to use an ADO connection. I've tried unsuccessfully to get other connection types to work (DSN, etc).

How can I get my 64 bit version to connect to the DB without the Login Failed message?

Also, this DLL and app needs to run on Windows 10. Are there any special steps, other than installing the Redist Pk, to setting up a Win 10 system for Crystal Reports viewer apps?

m_RptDoc = newReportDocument();

ConnectionInfo connectionInfo = newConnectionInfo();

TableLogOnInfo tableLogOnInfo = newTableLogOnInfo();

string databasePathFile = m_ReportDataPath + "\\" + m_ReportDatabaseFileName;

string reportPathFile = m_ReportPath + "\\" + m_ReportFileName;

connectionInfo.ServerName = databasePathFile;

connectionInfo.DatabaseName = databasePathFile;

connectionInfo.UserID = string.Empty; // "Admin";

connectionInfo.Password = string.Empty;

// load report

m_RptDoc.Load(reportPathFile);

Tables tables = m_RptDoc.Database.Tables;

foreach (Table table in tables)

{

tableLogOnInfo = table.LogOnInfo;

tableLogOnInfo.ConnectionInfo = connectionInfo;

table.ApplyLogOnInfo(tableLogOnInfo);

}

m_RptDoc.Refresh();

// show the report

//turn off the GroupTree View and button

crystalRptViewer.ToolPanelView = ToolPanelViewType.None;

crystalRptViewer.ShowGroupTreeButton = false;

crystalRptViewer.ShowParameterPanelButton = true; // false;

crystalRptViewer.Refresh();

crystalRptViewer.ReportSource = m_RptDoc;

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

4 Answers

  • Best Answer
    Jun 07, 2017 at 03:11 PM

    Office/Access 64 bit requires a 64 bit version to be installed. It does not have a 64 bit ADO/ODBC client installed by default.

    Not sure why it's working for you though when hitting refresh.

    Check the dependencies, it may be using a 32 bit client.

    Don

    Add comment
    10|10000 characters needed characters exceeded

  • Jun 08, 2017 at 03:30 PM

    As for Windows 10 compatibility, it depends on which service pack of the SDK you're using. I believe it has to be on SP15 or newer in order to be compatible with Windows 10. You can't just install the newer runtime and expect it to work with code that was compiled with an older version of the SDK - the code needs to be compiled with the same version of the SDK as the runtime.

    -Dell

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jun 13, 2017 at 10:36 PM

    I finally have the application running on my development notebook in 32 and 64 bit versions. However it won't work on the production box in 64 bit mode. I am trying to overwrite the connection info in the rpt file with hard coded values in my C# code but it doesn't seem to be affecting the loading of the report at runtime.

    On my development box I even put in the wrong server name and database name to see if it would fail but it doesn't. It loads and shows the report. On the production box it will try to load the report but gives me the login screen no matter what I use for connection info.

    If I comment out the code that loads the connectioninfo it will load and view the report fine on both machines (IF I have the report files and database in the same path as the rpt file's datasource location was set to). If the files / database are in a different path nothing works.

    If I use the connectioninfo code and try to point the report to a different path, it doesn't work.

    How do you control the login through code? The rpt file will load in VS 2015 and I can preview the report, refresh it etc. I can't figure out why won't they load and view on a production box where the path to the database is different than my development box?

    I've included my latest version that works on both machines only if the database and rpt files are in the same path as the report was configured for.

    Thank you for any direction you could give. I've been working on this for a while now and need to move on.

            public void ConfigCrystalRpts()
    
            {
    
                RptList.SelectedItem = 1;
    
                RptList.Update();
    
                string reportPath = Path.GetFullPath(RptList.SelectedItem.ToString());
    
                                                                                               
    
                ReportDocument RptDoc = new ReportDocument() ;
    
                RptDoc.Load(reportPath);
    
    
                ConnectionInfo connectionInfo = new ConnectionInfo();
    
                connectionInfo.UserID = "";
    
                connectionInfo.Password = "";
    
                connectionInfo.ServerName = "Optimizer.mdb";
    
                connectionInfo.DatabaseName = "Optimizer.mdb";
    
    
                SetDBLogonForReport(connectionInfo, RptDoc);
    
    
                CRV1.ReportSource = reportPath;
    
                CRV1.RefreshReport();
    
            }
    
    
            private void SetDBLogonForReport(ConnectionInfo connectionInfo, ReportDocument reportDocument)
    
            {
    
                Tables tables = reportDocument.Database.Tables;
    
                foreach (CrystalDecisions.CrystalReports.Engine.Table table in tables)
    
                {
    
                    TableLogOnInfo tableLogonInfo = table.LogOnInfo;
    
                    tableLogonInfo.ConnectionInfo = connectionInfo;
    
                    table.ApplyLogOnInfo(tableLogonInfo);
    
                }
    
    
                foreach (ReportDocument subreport in reportDocument.Subreports)
    
                {
    
                    foreach (CrystalDecisions.CrystalReports.Engine.Table CrTable in subreport.Database.Tables)
    
                    {
    
                        TableLogOnInfo tableLogonInfo = CrTable.LogOnInfo;
    
                        tableLogonInfo.ConnectionInfo = connectionInfo;
    
                        CrTable.ApplyLogOnInfo(tableLogonInfo);
    
                    }
    
                }
    
            }
    

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jun 13, 2017 at 04:20 PM

    Thanks for the hint on dependencies. I removed the Crystal dependencies and added them back making sure I used the latest version. After that the project would run and display the reports in the viewer on my development box in 32 bit mode. So that was definitely one problem I had.

    I am using CRforVS_13_0_20 on my development box with VS 2015 and have installed the CRforVS_redist_install_64bit_13_0_20 on the target machine which is on Windows 10. I've recompiled the application using CR version 20 for both 32 and 64 bit and only the 32 bit will show a report on either box. When I try to view a report using the 64 bit version it opens up the Database Login screen. No matter what I put in these fields it won't login.

    So now the problem seems to be either with how I've configured the report rpt files to log into the database for use with the 64 bit application or how my code is trying to load and login to the database. I've tried DNS, OLEDB, etc. but I've not found a combination that works. What is the proper way to configure the report files to connect to an Access database with at 64 bit application? It would be great if you could provide a rpt configuration and sample code snippet that shows how to load the report using ADO (or whatever method is preferred) in a 64 bit app.

    Login using 64 bit version:

    My rpt files are configured using ADO:

    Add comment
    10|10000 characters needed characters exceeded