问题描述
我想将列表对象传递给数据集,然后在Crystal报表中查看数据.我编写了以下代码,但是它似乎不起作用,数据没有出现在报表中.并显示您要求的报告需要更多信息."
请帮助我解决这个问题,thanx
受保护的void ButtonView_Click(对象发送者,EventArgs e)
{
SongsExtraBD sngexbd =新的SongsExtraBD();
列出< tblsongs> objSongList = new List< tblsongs>();
objSongList = sngexbd.GetDownLoadList();
dsTest mydsTest =新的dsTest();
DataTable objDataTable =新的DataTable("tblSongs");
objDataTable.Columns.Add("SongID");
objDataTable.Columns.Add("Name");
objDataTable.Columns.Add("Rate");
objDataTable.Columns.Add("Language");
DataRow myDataRow;
foreach(objSongList中的tblSong tblsng)
{
myDataRow = objDataTable.NewRow();
myDataRow [0] = tblsng.SongID;
myDataRow [1] = tblsng.Name;
myDataRow [2] = tblsng.tblrates.Rate;
myDataRow [3] = tblsng.Language;
objDataTable.Rows.Add(myDataRow);
}
mydsTest.Tables.Add(objDataTable);
rptDownLoad报告=新的rptDownLoad();
report.SetDataSource(mydsTest);
crptViewer.ReportSource =报告;
}
I want to pass my list object to a data set and then view data in crystal report.I have written following code but its not seems to be working, data is not appearing in the report. and it says "The report you requested requires further information."
pls help me to solve this issue , thanx
protected void ButtonView_Click(object sender, EventArgs e)
{
SongsExtraBD sngexbd = new SongsExtraBD();
List<tblsongs> objSongList = new List<tblsongs>();
objSongList = sngexbd.GetDownLoadList();
dsTest mydsTest = new dsTest();
DataTable objDataTable = new DataTable("tblSongs");
objDataTable.Columns.Add("SongID");
objDataTable.Columns.Add("Name");
objDataTable.Columns.Add("Rate");
objDataTable.Columns.Add("Language");
DataRow myDataRow;
foreach (tblSong tblsng in objSongList)
{
myDataRow = objDataTable.NewRow();
myDataRow[0] = tblsng.SongID;
myDataRow[1] = tblsng.Name;
myDataRow[2] = tblsng.tblrates.Rate;
myDataRow[3] = tblsng.Language;
objDataTable.Rows.Add(myDataRow);
}
mydsTest.Tables.Add(objDataTable);
rptDownLoad report = new rptDownLoad();
report.SetDataSource(mydsTest);
crptViewer.ReportSource = report;
}
推荐答案
report.SetDataSource(dataTable);
或
or
report.SetDataSource(dataset.tables[0]);
那么我确定它需要登录信息
then i''m sure it needs login information
report.SetDatabaseLogon(DBUserID, DBPwd);
让我知道是否仍然麻烦
问候,
thatraja
let me know if still trouble
Regards,
thatraja
这篇关于将列表对象分配给Crystal报表中的数据集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!