载入报告失败ERROR [英] Load report failed ERROR

查看:92
本文介绍了载入报告失败ERROR的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好
我是新成员.我的英语不好!
为什么此代码加载报告失败"错误?
谢谢.

Hello
I''m a new member. My English is poor!
Why is this code Load Report Failed error?
Thank you.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
using CrystalDecisions.Shared;
using CrystalDecisions.Windows.Forms;
using CrystalDecisions.CrystalReports.Engine;

namespace WindowsFormsApplication2
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        private void SetLogin(ConnectionInfo connectioninfo,ReportDocument reportdocument)
        {
            TableLogOnInfos TbLogOnInfos = crystalReportViewer1.LogOnInfo;
            foreach (TableLogOnInfo TbLogOnInfo in TbLogOnInfos)
                TbLogOnInfo.ConnectionInfo = connectioninfo;
            Tables tables = reportdocument.Database.Tables;
            foreach (Table table in tables)
            {
                TableLogOnInfo tbllogoninfo = table.LogOnInfo;
                tbllogoninfo.ConnectionInfo = connectioninfo;
                table.ApplyLogOnInfo(tbllogoninfo);
            }         
        }       
        private void Form1_Load(object sender, EventArgs e)
        {
            ReportDocument RepDoc = new ReportDocument();
            ConnectionInfo connectioninfo = new ConnectionInfo();
            connectioninfo.ServerName = "(local)";
            connectioninfo.Password = "123";
            connectioninfo.UserID = "sa";
            connectioninfo.DatabaseName = "Gold_Database";
            string RepPach = Application.StartupPath + @"\WindowsFormsApplication2\CrystalReport2.rpt";
            crystalReportViewer1.ReportSource = RepPach; // ---------Invalid report file path ERROR
            RepDoc.Load(RepPach);
            crystalReportViewer1.ReportSource = RepDoc;
            SetLogin(connectioninfo, RepDoc);           
        }       
    }
}

推荐答案

检查晶体位于给定路径的位置.
您可以调试代码,在string RepPach = Application.StartupPath + @"\WindowsFormsApplication2\CrystalReport2.rpt";上放置一个断点,然后在此处读取文件路径.
检查文件是否在该路径下.
CHeck that the crystal resides at the given path.
You can debug through the code, put a break point on string RepPach = Application.StartupPath + @"\WindowsFormsApplication2\CrystalReport2.rpt";, and then read the file path here.
Check if the file exists at that path.


Application.StartupPath = "G:\WindowsFormsApplication2\WindowsFormsApplication2\bin\Debug"
//Crystal in this direction is
"G:\WindowsFormsApplication2\WindowsFormsApplication2"

//RepPach of the break point is NULL

//With this command gives error
string RepPach = Application.StartupPath + @"..\..\CrystalReport2.rpt";

--Please help me.
--Thanks.


这篇关于载入报告失败ERROR的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆