Crystal Reports中找不到文件异常 [英] File Not Found Exception in Crystal Reports
本文介绍了Crystal Reports中找不到文件异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
使用Crystal Report并编写其关联代码并运行它后,我收到找不到文件的例外。因此IM无法生成报告。
如何解决此异常?
使用系统;
使用 System.Collections.Generic;
使用 System.ComponentModel;
// 使用System.Data;
使用 System.Drawing;
使用 System.Linq;
使用 System.Text;
使用 System.Windows.Forms;
使用 CrystalDecisions.CrystalReports.Engine;
使用 CrystalDecisions.Shared;
使用 System.Data;
使用 System.Data.SqlClient;
使用 System.Configuration;
// 使用System.Data.SqlClient;
< span class =code-comment> // 使用System.Configuration;
// 使用CrystalDecisions.Shared;
// 使用CrystalDecisions.CrystalReports.Engine;
命名空间 CrystalReportDemo
{
public partial class Form1:Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load( object sender,EventArgs e)
{
CrystalReport1 cr = new CrystalReport1();
EmployeeDataSetTableAdapters.EMPLYOEETableAdapter aa = new EmployeeDataSetTableAdapters.EMPLYOEETableAdapter();
EmployeeDataSet.EMPLYOEEDataTable table = aa.GetData();
cr.SetDataSource(table.DefaultView);
crystalReportViewer1.ReportSource = cr;
crystalReportViewer1.Refresh();
}
}
}
更正格式和语法问题。
已添加预
标签。
添加了正确的标题和说明。
[/ Edit]
解决方案
您没有使用ReportDocument
对象。示例代码应如下所示
private void button1_Click( object sender,EventArgs e)
{
ReportDocument cryRpt = new ReportDocument();
cryRpt.Load( PUT CRYSTAL REPORT PATH HERE \\CrystalReport1.rpt );
crystalReportViewer1.ReportSource = cryRpt;
crystalReportViewer1.Refresh();
}
查看本教程&它的系列
C#Crystal Reports一步一步 [ ^
After using Crystal Report and writing its associated Code and running it I am getting an Exception of "File Not Found". Thus I M Unable To Generate Reports.
How this Exception can be solved?
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 CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
//using System.Data.SqlClient;
//using System.Configuration;
//using CrystalDecisions.Shared;
//using CrystalDecisions.CrystalReports.Engine;
namespace CrystalReportDemo
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
CrystalReport1 cr = new CrystalReport1();
EmployeeDataSetTableAdapters.EMPLYOEETableAdapter aa = new EmployeeDataSetTableAdapters.EMPLYOEETableAdapter();
EmployeeDataSet.EMPLYOEEDataTable table = aa.GetData();
cr.SetDataSource(table.DefaultView);
crystalReportViewer1.ReportSource = cr;
crystalReportViewer1.Refresh();
}
}
}
[Edit member="Tadit"]
Corrected formatting and grammatical issues.
Added pre
tags.
Added correct Title and Description.
[/Edit]
解决方案
You didn't load the report file usingReportDocument
object. Sample code should be like below
private void button1_Click(object sender, EventArgs e) { ReportDocument cryRpt = new ReportDocument(); cryRpt.Load("PUT CRYSTAL REPORT PATH HERE\\CrystalReport1.rpt"); crystalReportViewer1.ReportSource = cryRpt; crystalReportViewer1.Refresh(); }
Check this tutorial & its series
C# Crystal Reports step by step[^]
这篇关于Crystal Reports中找不到文件异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文