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();
}
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.
精彩评论