<tfoot id='C98Yd'></tfoot>

<i id='C98Yd'><tr id='C98Yd'><dt id='C98Yd'><q id='C98Yd'><span id='C98Yd'><b id='C98Yd'><form id='C98Yd'><ins id='C98Yd'></ins><ul id='C98Yd'></ul><sub id='C98Yd'></sub></form><legend id='C98Yd'></legend><bdo id='C98Yd'><pre id='C98Yd'><center id='C98Yd'></center></pre></bdo></b><th id='C98Yd'></th></span></q></dt></tr></i><div id='C98Yd'><tfoot id='C98Yd'></tfoot><dl id='C98Yd'><fieldset id='C98Yd'></fieldset></dl></div>
  • <small id='C98Yd'></small><noframes id='C98Yd'>

  • <legend id='C98Yd'><style id='C98Yd'><dir id='C98Yd'><q id='C98Yd'></q></dir></style></legend>
        • <bdo id='C98Yd'></bdo><ul id='C98Yd'></ul>
      1. 水晶报表,为什么我提供了详细信息后仍然要求登录数据库?

        时间:2023-07-10

              <legend id='XFANa'><style id='XFANa'><dir id='XFANa'><q id='XFANa'></q></dir></style></legend>

                <bdo id='XFANa'></bdo><ul id='XFANa'></ul>

                <small id='XFANa'></small><noframes id='XFANa'>

                  <tbody id='XFANa'></tbody>
                  <tfoot id='XFANa'></tfoot>
                  <i id='XFANa'><tr id='XFANa'><dt id='XFANa'><q id='XFANa'><span id='XFANa'><b id='XFANa'><form id='XFANa'><ins id='XFANa'></ins><ul id='XFANa'></ul><sub id='XFANa'></sub></form><legend id='XFANa'></legend><bdo id='XFANa'><pre id='XFANa'><center id='XFANa'></center></pre></bdo></b><th id='XFANa'></th></span></q></dt></tr></i><div id='XFANa'><tfoot id='XFANa'></tfoot><dl id='XFANa'><fieldset id='XFANa'></fieldset></dl></div>
                • 本文介绍了水晶报表,为什么我提供了详细信息后仍然要求登录数据库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在生成一个报告,但问题是即使我提供了凭据,当包含 CrystalReport 的表单打开时,它仍然要求我提供它们,最糟糕的是,我没有输入任何内容在那里,只需单击完成,它就会加载报告.那么,如果不需要凭据(或其他),它为什么要问我?

                  I am generating a report, but the problem is even though I've supplied credentials, when the form containing the CrystalReport opens up, it still asks me for them, and the worst part is, I don't enter any thing in there, and just click finish, and it loads the report. So, if there is no need for credentials (or whatever) why is it asking me?

                  这是代码

                      private void MainReport_Load(object sender, EventArgs e)
                      {
                          var constr = string.Empty;
                          constr = Application.StartupPath;
                          if (Generate.bForProjects)
                              constr = Path.Combine(constr, @"ReportsProjects.rpt");
                          else
                              constr = Path.Combine(constr, @"ReportsOther.rpt");
                  
                          var myConInfo = new CrystalDecisions.Shared.TableLogOnInfo();
                          reportDocument1.Load(constr);
                          myConInfo.ConnectionInfo.DatabaseName = "ProjectData.mdb";
                          myConInfo.ConnectionInfo.ServerName = Application.StartupPath + @"DataProjectData.mdb";
                          myConInfo.ConnectionInfo.Password = "";
                          myConInfo.ConnectionInfo.UserID = "";
                          reportDocument1.Database.Tables[0].ApplyLogOnInfo(myConInfo);
                  
                          reportDocument1.Refresh();
                  
                          crystalReportViewer1.ReportSource = reportDocument1;
                          crystalReportViewer1.Width = this.Width - 50;
                          crystalReportViewer1.Height = this.Height - 100;
                      }
                  

                  当表单加载时,会弹出这个屏幕

                  When the form loads, this screen pop ups

                  而且,当出现这种情况时,我什么都不输入!那就对了!我只需单击完成,它就会完美地加载报告!那么,如果它不需要任何东西,为什么它会要求我登录?

                  推荐答案

                  当我们将水晶报表连接到与设计/创建它的数据库不同的数据库时,我们遇到了很多问题.我们最终创建了以下函数来正确设置它.它递归地设置所有报表表和子报表的连接.

                  We have lots of problems when we came to connect a crystal report to a different database to the one it was designed / created against. We ended up creating the following function to set it up correctly. It recursively sets the connection on all report tables and sub reports.

                  我似乎还记得,如果报告是使用集成 Windows 身份验证设计的,并且使用简单的用户名和密码运行,我们就会遇到问题.因此,我们始终确保使用简单的用户名和密码连接到数据库来设计报告.

                  Also I seem to remember we had problems if the report was designed with Integrated Windows Authentications, and run with a simple username and password. So we always made sure we designed the reports with a simple username and password connection to the database.

                  private static void SetConnection(ReportDocument report, string databaseName, string serverName, string userName, string password)
                  {
                      foreach (Table table in report.Database.Tables)
                      {
                          if (table.Name != "Command")
                          {
                              SetTableConnectionInfo(table, databaseName, serverName, userName, password);
                          }
                      }
                  
                      foreach (ReportObject obj in report.ReportDefinition.ReportObjects)
                      {
                          if (obj.Kind != ReportObjectKind.SubreportObject)
                          {
                              return;
                          }
                  
                          var subReport = (SubreportObject)obj;
                          var subReportDocument = report.OpenSubreport(subReport.SubreportName);
                          SetConnection(subReportDocument, databaseName, serverName, userName,  password);
                      }
                  }
                  
                  private static void SetTableConnectionInfo(Table table, string databaseName, string serverName, string userName, string password)
                  {
                      // Get the ConnectionInfo Object.
                      var logOnInfo = table.LogOnInfo;
                      var connectionInfo = logOnInfo.ConnectionInfo;
                  
                      // Set the Connection parameters.
                      connectionInfo.DatabaseName = databaseName;
                      connectionInfo.ServerName = serverName;
                      connectionInfo.Password = password;
                      connectionInfo.UserID = userName;
                      table.ApplyLogOnInfo(logOnInfo);
                  
                      if (!table.TestConnectivity())
                      {
                          throw new ApplicationException(Resource.UnableToConnectCrystalReportToDatabase);
                      }
                  
                      table.Location = Database + "." + "dbo" + "." + table.Location;
                  }
                  

                  这篇关于水晶报表,为什么我提供了详细信息后仍然要求登录数据库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:合并内存流以在 c# 中创建 http PDF 响应 下一篇:不使用打印机选择对话框打印

                  相关文章

                    <tfoot id='COlGg'></tfoot>
                      <bdo id='COlGg'></bdo><ul id='COlGg'></ul>
                    <i id='COlGg'><tr id='COlGg'><dt id='COlGg'><q id='COlGg'><span id='COlGg'><b id='COlGg'><form id='COlGg'><ins id='COlGg'></ins><ul id='COlGg'></ul><sub id='COlGg'></sub></form><legend id='COlGg'></legend><bdo id='COlGg'><pre id='COlGg'><center id='COlGg'></center></pre></bdo></b><th id='COlGg'></th></span></q></dt></tr></i><div id='COlGg'><tfoot id='COlGg'></tfoot><dl id='COlGg'><fieldset id='COlGg'></fieldset></dl></div>
                    <legend id='COlGg'><style id='COlGg'><dir id='COlGg'><q id='COlGg'></q></dir></style></legend>

                    <small id='COlGg'></small><noframes id='COlGg'>