我正在使用3层架构..
Public Function SelectVoucher() As DataSet
Try
Squery = "select a.VoucherNo,convert(char(10),a.VoucherDate,120) as VoucherDate,
a.TotDebit,b.CustomerName as PartyName,c.Particulars
from spendmoney a,mcustomermaster b,spendmoneychild c
where a.partycode=b.customercode and a.voucherno=c.voucherno and
a.voucherno=3"
Return objdal.DBread(Squery)
Catch ex As Exception
Throw ex
End Try
End Function
这是我使用的查询,但此查询不显示水晶报告..
显示所有字段..
但原始查询答案如下:
3 2011-08-28 1500 prakash www
这是我使用的编码。
sub crystalreport
Dim ds As New DataSet
Dim objrpt As New CrystalReport10
ds = bol.SelectVoucher()
If ds.Tables(0).Rows.Count > 0 Then
objrpt.SetDataSource(bol.SelectVoucher())
CrystalReportViewer1.ReportSource = objrpt
objrpt.Refresh()
CrystalReportViewer1.RefreshReport()
End If
end sub
如何将查询传递给Crystal Reports?
答案 0 :(得分:0)
摘自Crystal Reports for .NET SDK Samples中发布的'NET-CS2003_RAS-Unmanaged_CR115_Modify_Command-Table-SQL.zip'示例:
// Crystal Reports declarations
CrystalDecisions.CrystalReports.Engine.ReportDocument boReportDocument = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
CrystalDecisions.ReportAppServer.ClientDoc.ISCDReportClientDocument boReportClientDocument;
CrystalDecisions.ReportAppServer.Controllers.DataDefController boDataDefController;
CrystalDecisions.ReportAppServer.DataDefModel.Database boDatabase;
CrystalDecisions.ReportAppServer.DataDefModel.CommandTable boCommandTable;
// Load the report using the CR .NET SDK and get a handle on the ReportClientDocument
boReportDocument.Load(Server.MapPath("Command table report.rpt"));
boReportClientDocument = boReportDocument.ReportClientDocument;
// Use the DataDefController to access the database and the command table.
// Then display the current command table SQL in the textbox.
boDataDefController = boReportClientDocument.DataDefController;
boDatabase = boDataDefController.Database;
boCommandTable = (CrystalDecisions.ReportAppServer.DataDefModel.CommandTable)boDatabase.Tables[0];
boCommandTable.CommandText = sQuery;
// Clean up
boReportDocument.Close();
boReportDocument.Dispose();