我在C sharp中使用SAP CR for VS 2010。我有五個表,我將它們與以下查詢鏈接:SAP Crystal Reports for VS 2010.在運行時更改查詢
query =「SELECT Items.AccessionNo,Items.Name,Items.LocalName,Items.Usage,Items.Province,Items.District,Items.VillTown, Items.EthnicCommunity,Arts.Name,Items.PurchasedDonated,Items.PurchasedFrom,Items.YearOfCollection,Items.Material,Items.Height,Items.Width,Items.Length,Items.Circumference,Items.Diameter,Items.Color,Items。年齡,Items.Weight,Items.PurchasedValue,Items.Rare,Items.LivingDyingTrad,Items.ManufacturingProcess,Items.PlaceOfManufacturing,Items.ConditionReport,Items.Recommandations,Items.DateOfAddition,Items.Placement,Donators.Name,Collectors.Name, Placement.Name FROM Items INNER JOIN Arts ON Items.ArtId = Arts.ArtId INNER JOIN Donators ON Items.DonatorId = Donators.id INNER JOIN Collectors ON Items.CollectorId = Collectors.id INNER JOIN Placement ON Items.PlacementId = Pla cement.id WHERE Items.id =「+ itemid;
問題是報告在設計時仍然使用已嵌入的查詢顯示多個結果。
我使用下面的代碼通過上面的查詢
SqlCommand cmd = new SqlCommand(query, dbconn.conn);
if (dbconn.conn.State == ConnectionState.Closed)
{
dbconn.conn.Open();
}
SqlDataAdapter Datadpt = new SqlDataAdapter(cmd);
DataSet dtset = new DataSet("items");
Datadpt.Fill(dtset);
//rep is the Report document object already defined
rep.Load(@"..\..\Reports\CRItem.rpt");
rep.SetDataSource(dtset);
CRViewer.ReportSource = rep;
if (dbconn.conn.State == ConnectionState.Open)
{
dbconn.conn.Close();
}
this.CRViewer.RefreshReport();
有什麼建議?
結果是否都具有相同的'Items.id'值? – 2012-03-29 07:46:33
否。報告顯示數據庫中的所有行。它不根據查詢過濾數據。 – user1300054 2012-03-29 08:23:15
做'this.CRViewer.Refresh();'做任何不同的'this.CRViewer.RefreshReport();'? – 2012-03-29 09:27:41