简体   繁体   English

Crystal Report询问Simple Dataset的登录信息。 如何隐藏它?

[英]Crystal Report ask Logon information for Simple Dataset. How to hide it?

I know that there are some threads have a similar issue with this thread. 我知道有一些线程与此线程有类似的问题。 But, I couldn't find one which solve my problem. 但是,我找不到解决我问题的方法。

I use Visual Studio 2010 and I create a dataset with one table. 我使用Visual Studio 2010并使用一个表创建数据集。 I want to show the data in the Crystal Report Viewer. 我想在Crystal Report Viewer中显示数据。 But when it begins to load, it asks me login information. 但是当它开始加载时,它会询问我登录信息。 I don't set anything about login information on my dataset. 我没有对我的数据集上的登录信息进行任何设置。 That's why I'm confused. 这就是为什么我很困惑。

This is my code for adding a dummy row in the table: 这是我在表中添加虚拟行的代码:

dataSet = new DummyDS();
dummyTable = dataSet.Tables["Simulation"];

// fill table with random data
Object[] dummyObj = new Object[3];
dummyObj[0] = null;
dummyObj[1] = 1;
dummyObj[2] = 2;
dummyTable.Rows.Add(dummyObj);

This is my code for loading the crystal report viewer: 这是我加载水晶报表查看器的代码:

CrystalReport1 cr = new CrystalReport1();
cr.Load();

crystalReportViewer1.ReportSource = cr;
crystalReportViewer1.Refresh();

I want to show my data in Crystal Report Viewer without being asked for logon information. 我想在Crystal Report Viewer中显示我的数据,而不会要求您提供登录信息。 Could you help me to solve this problem? 你能帮我解决这个问题吗? Thank you in advance. 先感谢您。

From my experience : The Logon window could appear in these cases : 根据我的经验:在这些情况下可能会出现登录窗口:

  • Database connection string not provided (to do that Use 未提供数据库连接字符串(为此使用
    CrystalReport1.SetDatabaseLogon("UserID", "Password", "Server",
    "DatabaseName")
    CrystalReport1.SetDatabaseLogon("UserID", "Password", "Server",
    "DatabaseName")
    )
    CrystalReport1.SetDatabaseLogon("UserID", "Password", "Server",
    "DatabaseName")
  • The query contains nonexisting objects. 该查询包含不存在的对象。
  • Some other cases that I haven't met yet. 还有一些我尚未见过的案例。

upgraded to answer status as I assume it was the answer: 升级到回答状态,因为我认为这是答案:

You need to set the report data source to the data set you have created. 您需要将报告数据源设置为您创建的数据集。 If you dont set the data source for the report to the dataset then you are relying on CR just guessing which dataset to use! 如果您没有将报表的数据源设置为数据集,那么您依靠CR只是猜测要使用哪个数据集!

I have the same problem sometimes but unfortunately it does not have anything to do with any login process (as you suspected). 我有时遇到同样的问题,但遗憾的是它与任何登录过程没有任何关系(如您所怀疑的那样)。 When CR fails to create a report, on some occasions the error being thrown will be something like: 当CR无法创建报告时,在某些情况下抛出的错误将类似于:

"Load report failed (Logon failed)" “加载报告失败(登录失败)”

which has nothing to do with the login itself. 这与登录本身无关。 Even if you do not use authentication at all, it might very well give you this error. 即使您根本不使用身份验证,它也可能会给您带来此错误。 I suggest exporting the report to disk, for example using ExportToDisk with the PDF option. 我建议将报告导出到磁盘,例如使用带有PDF选项的ExportToDisk This will probably also generate an error but you can catch it easily and it might give you more information. 这可能也会产生错误,但您可以轻松捕获它,它可能会为您提供更多信息。

In any case, I think the error lies in the report generation itself (not authentication), for example in record selection formulae, formatting formulae or in a group function. 在任何情况下,我认为错误在于报告生成本身(不是身份验证),例如在记录选择公式,格式化公式或组函数中。 Or some other mismatch between the schema CR expects and the actual data you are providing. 或者模式CR期望与您提供的实际数据之间的其他一些不匹配。

The dummy data you are creating and putting in the report, does it have the exact same schema as the one you built the CR file with? 您正在创建并放入报表的虚拟数据,它是否与您构建CR文件的模式具有完全相同的模式?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM