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

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

  1. <small id='VwnGx'></small><noframes id='VwnGx'>

    1. 如何为水晶报表设置数据库登录信息(连接信息)?

      时间:2023-07-10

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

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

              <legend id='lY8ns'><style id='lY8ns'><dir id='lY8ns'><q id='lY8ns'></q></dir></style></legend>
                <tbody id='lY8ns'></tbody>

              • 本文介绍了如何为水晶报表设置数据库登录信息(连接信息)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我有一个应用程序(不是我的编码),它有很多水晶报告.我面临的问题是,每次我打开水晶报告时,它都会询问登录用户名和密码.

                I have an application (NOT MY Coding) which have a lot of crystal reports. the problem I'm facing is that every time i open a crystal report it asks for login username and password.

                经过一番搜索后,我发现我必须在运行时为报告设置连接信息,我找到了一些解决方案,但是当我查看应用程序的代码时,并没有像我预期的那样找到它.

                after a little search i found that i have to set the connectioninfo for the report at run time and i found some solution but when i looked at the code of the application i didn't find it as i was expecting.

                frmviewrpt(具有水晶报表查看器的表单)有这样的东西:

                the frmviewrpt (the form that has the crystal report viewer) have some thing like this:

                RptProBalance rptProductBalance = new RptProBalance();
                rptProductBalance.RecordSelectionFormula = getBalanceRptSelection();
                rptProductBalance.Refresh();
                allReportViewer.ReportSource = rptProductBalance; 
                

                RptProBalance()(从 RptProBalance.rpt 文件扩展而来的 cs 文件):

                the RptProBalance() (the cs file that is extended from the RptProBalance.rpt file):

                //------------------------------------------------------------------------------
                 // <auto-generated>
                 //     This code was generated by a tool.
                 //     Runtime Version:2.0.50727.42
                 //
                 //     Changes to this file may cause incorrect behavior and will be lost if
                 //     the code is regenerated.
                 // </auto-generated>
                 //------------------------------------------------------------------------------
                
                 namespace minfatora {
                using System;
                using System.ComponentModel;
                using CrystalDecisions.Shared;
                using CrystalDecisions.ReportSource;
                using CrystalDecisions.CrystalReports.Engine;
                
                
                public class RptProBalance : ReportClass {
                
                    public RptProBalance() {
                    }
                
                    public override string ResourceName {
                        get {
                            return "RptProBalance.rpt";
                        }
                        set {
                            // Do nothing
                        }
                    }
                
                    [Browsable(false)]
                    [DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
                    public CrystalDecisions.CrystalReports.Engine.Section ReportHeaderSection1 {
                        get {
                            return this.ReportDefinition.Sections[0];
                        }
                    }
                
                    [Browsable(false)]
                    [DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
                    public CrystalDecisions.CrystalReports.Engine.Section PageHeaderSection1 {
                        get {
                            return this.ReportDefinition.Sections[1];
                        }
                    }
                
                    [Browsable(false)]
                    [DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
                    public CrystalDecisions.CrystalReports.Engine.Section GroupHeaderSection1 {
                        get {
                            return this.ReportDefinition.Sections[2];
                        }
                    }
                
                    [Browsable(false)]
                    [DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
                    public CrystalDecisions.CrystalReports.Engine.Section DetailSection1 {
                        get {
                            return this.ReportDefinition.Sections[3];
                        }
                    }
                
                    [Browsable(false)]
                    [DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
                    public CrystalDecisions.CrystalReports.Engine.Section GroupFooterSection1 {
                        get {
                            return this.ReportDefinition.Sections[4];
                        }
                    }
                
                    [Browsable(false)]
                    [DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
                    public CrystalDecisions.CrystalReports.Engine.Section ReportFooterSection1 {
                        get {
                            return this.ReportDefinition.Sections[5];
                        }
                    }
                
                    [Browsable(false)]
                    [DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
                    public CrystalDecisions.CrystalReports.Engine.Section PageFooterSection1 {
                        get {
                            return this.ReportDefinition.Sections[6];
                        }
                    }
                }
                
                [System.Drawing.ToolboxBitmapAttribute(typeof(CrystalDecisions.Shared.ExportOptions), "report.bmp")]
                public class CachedRptProBalance : Component, ICachedReport {
                
                    public CachedRptProBalance() {
                    }
                
                    [Browsable(false)]
                    [DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
                    public virtual bool IsCacheable {
                        get {
                            return true;
                        }
                        set {
                            // 
                        }
                    }
                
                    [Browsable(false)]
                    [DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
                    public virtual bool ShareDBLogonInfo {
                        get {
                            return false;
                        }
                        set {
                            // 
                        }
                    }
                
                    [Browsable(false)]
                    [DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
                    public virtual System.TimeSpan CacheTimeOut {
                        get {
                            return CachedReportConstants.DEFAULT_TIMEOUT;
                        }
                        set {
                            // 
                        }
                    }
                
                    public virtual CrystalDecisions.CrystalReports.Engine.ReportDocument CreateReport()      {
                        RptProBalance rpt = new RptProBalance();
                        rpt.Site = this.Site;
                        return rpt;
                    }
                
                    public virtual string GetCustomizedCacheKey(RequestContext request) {
                        String key = null;
                        // // The following is the code used to generate the default
                        // // cache key for caching report jobs in the ASP.NET Cache.
                        // // Feel free to modify this code to suit your needs.
                        // // Returning key == null causes the default cache key to
                        // // be generated.
                        // 
                        // key = RequestContext.BuildCompleteCacheKey(
                        //     request,
                        //     null,       // sReportFilename
                        //     this.GetType(),
                        //     this.ShareDBLogonInfo );
                        return key;
                    }
                }
                 }
                

                我不知道我应该在哪里建立连接信息并将其传递给报告.

                I have no clue where exactly I'm supposed to make the connection info and pass it to the report.

                推荐答案

                ConnectionInfo crconnectioninfo = new ConnectionInfo();
                    ReportDocument cryrpt = new ReportDocument();
                    TableLogOnInfos crtablelogoninfos = new TableLogOnInfos();
                    TableLogOnInfo crtablelogoninfo = new TableLogOnInfo();
                
                    Tables CrTables;
                
                    crconnectioninfo.ServerName = "localhost";
                    crconnectioninfo.DatabaseName = "dbclients";
                    crconnectioninfo.UserID = "ssssssss";
                    crconnectioninfo.Password = "xxxxxxx";  
                
                
                  cryrpt.Load(Application.StartupPath + "\rpts\" + dealerInfo.ResourceName);
                
                        CrTables = cryrpt.Database.Tables;
                
                        foreach (CrystalDecisions.CrystalReports.Engine.Table CrTable in CrTables)
                        {
                            crtablelogoninfo = CrTable.LogOnInfo;
                            crtablelogoninfo.ConnectionInfo = crconnectioninfo;
                            CrTable.ApplyLogOnInfo(crtablelogoninfo);
                        }
                
                
                        cryrpt.RecordSelectionFormula = getCustInfoRptSelection();
                        cryrpt.Refresh();
                
                        allReportViewer.ReportSource = cryrpt;
                

                这篇关于如何为水晶报表设置数据库登录信息(连接信息)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:在 C# 中将参数传递给水晶报表 下一篇:水晶报表动态logo(图片)

                相关文章

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

                  <tfoot id='GfWwb'></tfoot>
                  • <bdo id='GfWwb'></bdo><ul id='GfWwb'></ul>

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

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