2011-04-20 123 views
0

您好即時通訊使用3層架構..如何將SQL查詢傳遞給Crystal Report?

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

從 'NET-CS2003_RAS-Unmanaged_CR115_Modify_Command-Table-SQL.zip' 樣品中提取的張貼在Crystal Reports for .NET SDK Samples

// 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(); 
相關問題