Why does Crystal Report Viewer always asks for login details to Access database on WePOS operating system?

13,697

Solution 1

Just for future reference, if you ever switch to SQL Server you will want to use SQL OLEDB and NOT the native Sql Client or you will run into the same problem again as I also did when I was first integrating CR into our app. It will work fine on your development machine but not in production.

Solution 2

DOes this WePos thing have the correct right to read from to folder/location in your filesystem or do you need elevated rights or something to read from this location. Could be the same issue when you connect to a remote network folder. Then you also have to specify the credentials on that computer to get access to it. Does this make sense?

Solution 3

Public Sub giveLogin()
            Dim conInfo As New ConnectionInfo
            conInfo.ServerName = ConfigurationManager.AppSettings("ServerName")
            conInfo.DatabaseName = ConfigurationManager.AppSettings("DatabaseName")
            conInfo.UserID = ConfigurationManager.AppSettings("UserID")
            conInfo.Password = ConfigurationManager.AppSettings("Password")
            For Each tblLogon As TableLogOnInfo In CrystalReportViewer1.LogOnInfo
                tblLogon.ConnectionInfo = conInfo
            Next
        End Sub

<CR:CrystalReportViewer ID="CrystalReportViewer1" runat="server" AutoDataBind="true" HasCrystalLogo ="False"  EnableDatabaseLogonPrompt ="false" EnableParameterPrompt ="false"  />

Solution 4

In Crystal Reports XI (possible on all version I'd imagine) I changed the Database Type from Access/Excel (DAO) to OLE DB (ADO).

I bet if I had persisted I could have set the location of the System.mdw against the reports Datasource Location in the C# code (see above), as indicated by David.

So many thanks David for the top notch steer towards the cause of this exceptionally 'niche' problem - I hope it helps someone else!


Added on behalf of the OP.

Share:
13,697
Admin
Author by

Admin

Updated on July 22, 2022

Comments

  • Admin
    Admin almost 2 years

    I wrote a report using Crystal Reports XI linked to an Access database here C:\MyData.mdb.

    The report has one field (simplified for this example) and no sub-reports.

    I have used the Forms and WPF Cyrtsal Report Viewer using C# .NET 4.

    The report views successfully on my development PC running Windows XP, and on other "tills", also running Windows XP.

    However, on a till running WePOS (a sort of cut down Windows XP) the report "always" shows a dialog box asking for login details i.e. Username & Password.

    This dialog box also shows the correct path to C:\MyData.mdb.

    I have spent many days on this, testing in every way possible (I'm sure everyone remembers times like these!).

    I use this code to ensure the database is correctly linked to:

    TableLogOnInfo logonInfo;
    
    foreach (CrystalDecisions.CrystalReports.Engine.Table table in report.Database.Tables)
    {
        logonInfo = table.LogOnInfo;
        logonInfo.ConnectionInfo.ServerName = string.Empty;
        logonInfo.ConnectionInfo.DatabaseName = "C:\MyData.mdb";
        logonInfo.ConnectionInfo.UserID = string.Empty;
        logonInfo.ConnectionInfo.Password = string.Empty;
        table.ApplyLogOnInfo(logonInfo);
    }
    

    ... and it works on every PC with Windows XP, except the one with WePOS.

    I've also played with:

    report.SetDatabaseLogon(string.Empty, string.Empty, "C:\MyData.mdb", string.Empty);
    

    ... but It makes no difference.

    1. There is no username or password on the Access database
    2. All the PC's used have the releveant software installed (runtimes, etc.)
    3. All the PC's were tested using the Adminstrator account (and file permissions were double checked)
    4. I've tried ticking the Integrated Security tick box, with no luck
    5. I set logonInfo.ConnectionInfo.DatabaseName = string.Empty;
    6. I set logonInfo.ConnectionInfo.ServerName = "C:\MyData.mdb";
    7. I have tried NOT using any of the above code, instead just made sure the database was in the same place on all PC's, with no luck
    8. It is an Access 2003 database file

    I can only conclude WePOS is so "cut down" that Crystal is silently failing to pass authentication... please help!