Crystal Reports for Visual Studio 2010中的SetDataSource失败 [英] SetDataSource fails in Crystal Reports for Visual Studio 2010

查看:62
本文介绍了Crystal Reports for Visual Studio 2010中的SetDataSource失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在Visual Studio 2010中使用简单的Crystal Report在WPF中工作。 当我尝试设置数据源(rpt.SetDataSource((DataTable)ds.Tables [0]);)时,应用程序崩溃,没有可捕获的异常。 我用来设置
数据集的代码如下:

I am trying to get a simple Crystal Report to work in WPF in Visual Studio 2010.  When I try to set the data source (rpt.SetDataSource((DataTable)ds.Tables[0]);) the application crashes with no trappable exception.  The code I am using to set up the dataset is as follows:

private
MainDataSet
获取DataSetFromList(
列表 < MainBvaReportRecord >
lst)
{

private MainDataSet GetDataSetFromList(List<MainBvaReportRecord> lst) {

MainDataSet
ds =
new
MainDataSet ();

MainDataSet ds = new MainDataSet();

MainDataSet BVA_TEST_DATA_VIEWDataTable
dt =(
MainDataSet BVA_TEST_DATA_VIEWDataTable )ds.Tables [0];  

MainDataSet.BVA_TEST_DATA_VIEWDataTable dt = (MainDataSet.BVA_TEST_DATA_VIEWDataTable)ds.Tables[0]; 

foreach
MainBvaReportRecord
rcd

lst)
DataRow
row = dt.NewRow();

foreach (MainBvaReportRecord rcd in lst) DataRow row = dt.NewRow();

row [&HOSPITAL_NAME" ]
= rcd.HospitalName;

row["HOSPITAL_NAME"] = rcd.HospitalName;

行[ " DEPARTMENT_NAME" ]
= rcd.DepartmentName;

row["DEPARTMENT_NAME"] = rcd.DepartmentName;

行[ " DEPARTMENT_ADDRESS" ]
= rcd.DepartmentAddress;

row["DEPARTMENT_ADDRESS"] = rcd.DepartmentAddress;

行[ " DEPARTMENT_DIRECTOR" ]
= rcd.DepartmentDirector;

row["DEPARTMENT_DIRECTOR"] = rcd.DepartmentDirector;

行[ " DEPARTMENT_PHONE_NUMBER" ]
= rcd.DepartmentPhoneNumber;

row["DEPARTMENT_PHONE_NUMBER"] = rcd.DepartmentPhoneNumber;

行[ " FIRST_NAME" ]
= rcd.FirstName;

row["FIRST_NAME"] = rcd.FirstName;

行[ " MIDDLE_NAME" ]
= rcd.MiddleName;

row["MIDDLE_NAME"] = rcd.MiddleName;

行[ " LAST_NAME" ]
= rcd.LastName;

dt.Rows.Add(row) ;

dt.Rows.Add(row);

 }

返回
ds;

}

我从Window_Loaded事件中的以下代码中调用它:

I call this from the following code in the Window_Loaded event:

private
void
Window_Loaded(
对象
发件人,
RoutedEventArgs
e)
{  

private void Window_Loaded(object sender, RoutedEventArgs e) { 

ViewerCore
view =
这个 。crystalReportsViewer.ViewerCore;

ViewerCore view = this.crystalReportsViewer.ViewerCore;

BVACrystalReport
rpt =
new
BVACrystalReport ();

BVACrystalReport rpt = new BVACrystalReport();

rpt.SetDatabaseLogon( " USERNAME"
" password"
@" Databasepath"
"数据库" );

rpt.SetDatabaseLogon("USERNAME", "password", @"Databasepath", "Database");

尝试

{

列表 < MainBvaReportRecord >
list =
new
MainBvaReportRecordDataAccess ()。SelectList();

List<MainBvaReportRecord> list = new MainBvaReportRecordDataAccess().SelectList();

MainDataSet
ds =
这个 。GetDataSetFromList(list);

MainDataSet ds = this.GetDataSetFromList(list);

rpt.SetDataSource(( DataTable )ds.BVA_TEST_DATA_VIEW);

}

catch
例外
ex)

MessageBox 。显示(ex.Message);

}

view.ReportSource = rpt;}

view.ReportSource = rpt;}

我在调用SetDataSource时尝试了各种组合,但都以相同的方式失败。 任何人都可以帮助我这个?

I have tried various combinations in the call to SetDataSource, but all fail in the same manner.  Can anyone help me with this?

 

推荐答案

你好,

您正在使用DS但是直接将报告登录到服务器:

You are using a DS but then setting the Report log on to the Server directly:

rpt.SetDatabaseLogon( " USERNAME"
" password"
@" Databasepath"
"数据库" );

rpt.SetDatabaseLogon("USERNAME", "password", @"Databasepath", "Database");

不要同时执行这两种操作,请使用rpt.SetDataSource(ds)方法。

Don't do both, use the rpt.SetDataSource( ds ) method.

此外,您正在使用Beta版本,现在升级到Service Pack 1或更高版本。

Also, you are using the Beta release, upgrade to Service Pack 1 or above now that it's available.

http://www.sdn .sap.com / irj / boc / crystalreports-dotnet

http://www.sdn.sap.com/irj/boc/crystalreports-dotnet


这篇关于Crystal Reports for Visual Studio 2010中的SetDataSource失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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