• <legend id='RJSik'><style id='RJSik'><dir id='RJSik'><q id='RJSik'></q></dir></style></legend>

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

    <tfoot id='RJSik'></tfoot>
      <bdo id='RJSik'></bdo><ul id='RJSik'></ul>

    <i id='RJSik'><tr id='RJSik'><dt id='RJSik'><q id='RJSik'><span id='RJSik'><b id='RJSik'><form id='RJSik'><ins id='RJSik'></ins><ul id='RJSik'></ul><sub id='RJSik'></sub></form><legend id='RJSik'></legend><bdo id='RJSik'><pre id='RJSik'><center id='RJSik'></center></pre></bdo></b><th id='RJSik'></th></span></q></dt></tr></i><div id='RJSik'><tfoot id='RJSik'></tfoot><dl id='RJSik'><fieldset id='RJSik'></fieldset></dl></div>
      1. 使用 C# 和 Sql server 创建 Crystal 报表

        Creating Crystal report with C# and Sql server(使用 C# 和 Sql server 创建 Crystal 报表)

          <tbody id='313CB'></tbody>

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

          • <bdo id='313CB'></bdo><ul id='313CB'></ul>
          • <legend id='313CB'><style id='313CB'><dir id='313CB'><q id='313CB'></q></dir></style></legend>
            1. <tfoot id='313CB'></tfoot>

                  <small id='313CB'></small><noframes id='313CB'>

                  本文介绍了使用 C# 和 Sql server 创建 Crystal 报表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在使用 Crystal 报告为我的应用程序生成报告,这是我使用的代码:

                  I'm using Crystal report to generate reports to my application, this is the code i used:

                  private void button5_Click(object sender, EventArgs e)
                      {
                          ReportDocument cryRpt = new ReportDocument();
                  
                          TableLogOnInfos crtableLogoninfos = new TableLogOnInfos();
                          TableLogOnInfo crtableLogoninfo = new TableLogOnInfo();
                          ConnectionInfo crConnectionInfo = new ConnectionInfo();
                          Tables CrTables;
                  
                          cryRpt.Load("C:\Documents and Settings\Administrateur\Mes documents\MyApplication\MyApplication\CrystalReport1.rpt");
                  
                          crConnectionInfo.ServerName = ".\SQLEXPRESS";
                          crConnectionInfo.DatabaseName = "database";
                          crConnectionInfo.UserID = "";
                          crConnectionInfo.Password = "";
                          crConnectionInfo.IntegratedSecurity = true;
                          CrTables = cryRpt.Database.Tables;
                  
                          foreach (CrystalDecisions.CrystalReports.Engine.Table CrTable in CrTables)
                          {
                              crtableLogoninfo = CrTable.LogOnInfo;
                              crtableLogoninfo.ConnectionInfo = crConnectionInfo;
                              CrTable.ApplyLogOnInfo(crtableLogoninfo);
                          }
                  
                          cryRpt.SetDatabaseLogon("", "", ".\SQLEXPRESS", "database");
                          crystalReportViewer1.ReportSource = cryRpt;
                          crystalReportViewer1.Refresh();
                      }
                  

                  但是当我运行应用程序时,会出现一个登录屏幕并要求连接 ID 和密码,我尝试输入空值,但连接失败.

                  But when i run the application, a login screen appeared and demands the connection Id and password, i tried to enter null values but the connection is failed.

                  问题出在哪里??

                  推荐答案

                  你必须初始化 DataSet 类的一个实例,并用来自的信息填充它

                  You have to initialize an instance of the DataSet class, and fill it with information from

                  您的数据集,因为 Crystal 报表数据源基于数据集.这是一个基本的代码

                  your DataSet because Crystal report Datasource is based on a dataset. This is a basic code of

                  将 Crystal 报表与数据集一起使用:

                  using Crystal report with Dataset:

                  SqlConnection con = new SqlConnection();
                          con.ConnectionString = @"Data Source=.SQLEXPRESS;AttachDbFilename=YOUR PATHdatabase.mdf;Integrated Security=True;User Instance=True";
                          con.Open();
                          string sql = "SELECT * FROM tablename";
                          SqlDataAdapter dscmd = new SqlDataAdapter(sql, con);
                          DataSet ds = new DataSet();
                          dscmd.Fill(ds, "tablename");
                          con.Close();
                  
                          CrystalReport1 objRpt = new CrystalReport1();
                          objRpt.SetDataSource(ds.Tables["tablename"]);
                          crystalReportViewer1.ReportSource = objRpt;
                          crystalReportViewer1.Refresh();
                  

                  这篇关于使用 C# 和 Sql server 创建 Crystal 报表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Adding DbContextOptions in Startup.cs not registering data store(在 Startup.cs 中添加 DbContextOptions 未注册数据存储)
                  Migrate html helpers to ASP.NET Core(将 html 帮助程序迁移到 ASP.NET Core)
                  Conditional validation in MVC.NET Core (RequiredIf)(MVC.NET Core 中的条件验证(RequiredIf))
                  Is it possible to serve static files from outside the wwwroot folder?(是否可以从 wwwroot 文件夹外部提供静态文件?)
                  Working with multiple resultset in .net core(在 .net 核心中使用多个结果集)
                  Where all types for http headers gone in ASP.NET 5?(ASP.NET 5 中所有类型的 http 标头都去了哪里?)

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

                      <tbody id='SHNjK'></tbody>
                    <tfoot id='SHNjK'></tfoot>

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

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