1
votes

PROBLEM: I see login Info window when loading report.

Tried alot. Read many forums but no success. Below is the code. I am using latest Crystal Report in VS2010. Windows forms.

I am using access db 2010 with password only. I am not sure what to use username and I never mentioned in access. My CrystalReportViewer is attached to DataSet which is ReportingDS.xsd .

Please help.

private static string StrCon = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + Application.ExecutablePath.ToString().Substring(0, Application.ExecutablePath.ToString().LastIndexOf('\\')) + "\\Reporting.accdb;Jet OLEDB:Database Password=abc;";
        public Report_Frm()
        {
            InitializeComponent();
        }

        private void Report_Frm_Load(object sender, EventArgs e)
        {

            ReportDocument cryRpt = new ReportDocument();

            cryRpt.Load(@"C:\Users\chris\Documents\Visual Studio 2010\Projects\ReportingSystem\ReportingSystem\myReport.rpt");

            cryRpt.SetDatabaseLogon("Admin", "abc", @"C:\Users\chris\Documents\Visual Studio 2010\Projects\ReportingSystem\ReportingSystem\ReportingDS", "Reporting.accdb");

            crystalReportViewer.ReportSource = cryRpt;
            //crystalReportViewer.Refresh();



            }
1
Does your database require a password? If you open the MDB file, does it prompt you for one (user id/password)? - craig
@craig , Yes I need password for db. - Pirzada
When you open this .MDB file with Microsoft Access, are you prompted to supply a user-id and password? If so, do these values ('Admin'/'abc') work (give you access to the file)? - craig

1 Answers

0
votes

The code worked for me without database prompting:

Dim reportDocument As New CrystalDecisions.CrystalReports.Engine.ReportDocument

'load report
reportDocument.Load("C:\Documents and Settings\Administrator\Desktop\customer.rpt")

'set user-id/password
reportDocument.SetDatabaseLogon("Admin", "abc")

'bind to viewer
Me.CrystalReportViewer1.ReportSource = reportDocument

The report uses an Access database connected via OLEDB.