#region GetCrystalPushReport
private ReportDocument GetCrystalPushReport(ReportDescriptor _Descriptor)
{
if(_Descriptor.Describes == null) {
throw new System.ArgumentNullException("Descriptor.Describes ") ;
}
Report Report = _Descriptor.Describes ;
ReportDocument Return = new ReportDocument() ;
DbDataProvider data = new DbDataProvider() ;
string filename = data.GetReportFile(Report) ;
Return.Load(filename) ;
//got the report
DataSet bar =
CrystalDataBuilder.GetInstance().GetReportData(_De scriptor);
SetReportDataSource(Return, bar);
return Return;
}
is what I use ... the Descriptor has metadata information associated with it
that describes the data to pull ...
private void SetReportDataSource(ReportDocument _Report, DataSet _ds) {
_Report.SetDataSource(_ds) ;
for (int i = 0; i < _Report.ReportDefinition.ReportObjects.Count; i++) {
ReportObject CurrentObject = _Report.ReportDefinition.ReportObjects[i];
if(CurrentObject.Kind ==
CrystalDecisions.Shared.ReportObjectKind.Subreport Object) {
ReportDocument SubReport =
_Report.OpenSubreport(((SubreportObject)CurrentObj ect).SubreportName);
SetReportDataSource(SubReport, _ds) ;
}
}
}
sets the data source for the report and all subreports ...
"laumon" <la****@discussions.microsoft.com> wrote in message
news:28**********************************@microsof t.com...
Hi,
I want to push data from a winform into a crystal report document but .
I found everithing in the FAQ 'crystal report' and other posts in forums
but it doesn't work. Here is my code.(it doesn't work).
***************
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click Dim crpt As New CrystalReport2
Dim strSQL As String = "SELECT * from products WHERE SupplierId =
1" Dim ds As New DataSet
Dim conn As SqlConnection = New
SqlConnection("server=turing;database=northwind;in tegrated security=true;") Dim da As SqlDataAdapter = New SqlDataAdapter(strSQL, conn)
conn.Open()
da.Fill(ds, "products")
conn.Close()
crpt.SetDataSource(ds)
CrystalReportViewer1.ReportSource = crpt
End Sub
***************
If someone could help me.
Thank you.