windows 水晶报表显示数据库登录要求?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3581905/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Crystal report shows database login requirement?
提问by A.P.S
I have created a crystal report using MySql 5.1, using XML (Dataset save as xml in application root folder) now when i run on my machine it works fine. But when app is installed on other machine it give database login required. how can i remove that login window ? The code is given below
我已经使用 MySql 5.1 创建了一个水晶报告,现在当我在我的机器上运行时,它使用 XML(数据集在应用程序根文件夹中另存为 xml)。但是当应用程序安装在其他机器上时,它需要数据库登录。我怎样才能删除那个登录窗口?代码如下
cDataSet.DataSetName = "TimeDataSet";
cDataSet.WriteXml(Application.StartupPath
+ "\" + "TimeDSReport.xml", XmlWriteMode.WriteSchema);
ReportDocument report = new ReportDocument();
report.Load(Application.StartupPath + "\" + "TimeTracker.rpt");
crystalReportViewer1.ReportSource = report;
Please see if the code is fine or i need to add some additional parameter?
请看看代码是否正常,或者我需要添加一些额外的参数?
Thanks PAL
谢谢菲航
回答by renjucool
Make sure that the Name or the DataTable in "Typed DataSet" and the Name DataTable that you assign as "RecordSource" to crystal reprort must be same
确保“Typed DataSet”中的 Name 或 DataTable 与您指定为“RecordSource”给 Crystal reprort 的 Name DataTable 必须相同
Or if u are using directly from database Set the logon information in your code as below
或者,如果您直接从数据库中使用,请在您的代码中设置登录信息,如下所示
private void ConfigureCrystalReports()
{
rpt= new ReportDocument();
string reportPath = Server.MapPath("reportname.rpt");
rpt.Load(reportPath);
ConnectionInfo connectionInfo = new ConnectionInfo();
connectionInfo.DatabaseName = "Northwind";
connectionInfo.UserID = "sa";
connectionInfo.Password="pwd";
SetDBLogonForReport(connectionInfo,rpt);
CrystalReportViewer1.ReportSource = rpt;
}