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

前端 未结 5 878
遇见更好的自我
遇见更好的自我 2021-02-07 13:16

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.

相关标签:
5条回答
  • 2021-02-07 13:58

    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?

    0 讨论(0)
  • 2021-02-07 14:02
    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"  />
    
    0 讨论(0)
  • 2021-02-07 14:07

    this works for me,

    var rd = new CrystalReport1();
                ConnectionInfo connectionInfo = new ConnectionInfo();
                connectionInfo.DatabaseName = @"d:\testing\test2.mdb";
                connectionInfo.UserID = "admin";
                foreach (Table table in rd.Database.Tables)
                {
                    TableLogOnInfo logonInfo = table.LogOnInfo;
                    logonInfo.ConnectionInfo = connectionInfo;
                    table.ApplyLogOnInfo(logonInfo);                
                }
                crystalReportViewer1.ReportSource = rd;
    
    0 讨论(0)
  • 2021-02-07 14:10

    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.

    0 讨论(0)
  • 2021-02-07 14:14

    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.

    0 讨论(0)
提交回复
热议问题