Crystal Report登录失败 [英] Crystal Report Login fail for access
问题描述
问题::加载报告时,我会看到登录信息窗口。
PROBLEM: I see login Info window when loading report.
尝试了很多。阅读了很多论坛,但没有成功。下面是代码。我在VS2010中使用最新的Crystal Report。 Windows窗体。
Tried alot. Read many forums but no success. Below is the code. I am using latest Crystal Report in VS2010. Windows forms.
我仅使用带密码的Access db 2010。我不确定要使用什么用户名,我在访问中从未提及。我的CrystalReportViewer附加到DataSet,即ReportingDS.xsd。
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 .
请帮助。
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
该报告使用通过OLEDB连接的Access数据库。
The report uses an Access database connected via OLEDB.
这篇关于Crystal Report登录失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!