Hi jlo,
Some options:
EXTERNAL REPORTS (as per your example
1) Parameterised report with Stored procedure
Ideally you would have a stored procedure in the database that takes the
'range' parameters.
The report would then be altered to have the sproc as its datasource and
it
would provide the parameters
2) Parameterised report straight from table
You can alter the report to have the range parameters and have it limit
the
table data displayed (Not as efficient.)
INTERNAL REPORT
(Disadvantage of internal report is new installation needed if report
changes.)
Assumes a datalayer in your application.
Make a typed dataset and fill it.
Design a internal report that takes the typed dataset as its datasource.
Hang that in the Report viewer
The visual studio crystal engine has all the necessary classes to allow
you
to manipulate the report before you hang it in the viewer.
Some c# code dealing with a parameterised external report and some vb
dealing with an internal report follows
hth
bob
/// <summary>
/// CrystalReportsParameters is a dll based on Bill Sergio's article
///
http://www.codeproject.com/useritems/crystalWin.asp
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void cmdView_Click(object sender, EventArgs e)
{
if (dgReports.SelectedRows.Count == 0) //Reports are listed in a grid
{
MessageBox.Show(rm.GetString("String133")); //pick a report
return;
}
this.Cursor = Cursors.WaitCursor;
CrystalDecisions.Shared.TableLogOnInfo t; //logging on to database
t = new CrystalDecisions.Shared.TableLogOnInfo();
t.ConnectionInfo.DatabaseName = mLogger.RegGetStringValue("MyApp",
"Database", "Server");
t.ConnectionInfo.UserID = "myuser";
t.ConnectionInfo.Password = "mypassword";
string sReportFile = mstrReportPath +
dgReports.SelectedRows[0].Cells[1].Value.ToString();
string sReport = dgReports.SelectedRows[0].Cells[1].Value.ToString();
ReportDocument r;
CrystalReportParameters.ICrystalParameters c = new
CrystalReportParameters.clsMain() ; // Pretty parameter screen courtesy of
Bill Sergio, otherwise use parameterfields collection of ReportDocument
r = c.DisplayParameters(sReport, sReportFile);//Displays parameters ,
takes
values returns ReportDoc
if(r!=null)
{
crv.LogOnInfo = new CrystalDecisions.Shared.TableLogOnInfos();//crv is the
Crystal Reports Viewer on the form
crv.LogOnInfo.Add(t);
crv.ReportSource = r;
}
else
{
MessageBox.Show(rm.GetString("String77"));
}
this.Cursor=Cursors.Default;
return;
**********Internal report *********
Private Sub loadReportLeasedMeter(ByRef ds As dsMeterCost)
Try
Dim rd As New ReportMeterInvoice
rd.SetDataSource(ds)
Me.crvMain.ReportSource = rd
Catch ex As Exception
WriteErrorLog("frmReport.loadReportReprogram " & ex.Message)
End Try
End Sub
***************************************
Jlo said:
Hi, I have a c# winforms application.
When I call the report file, it shows me all the records in the table.
How can I make it to call only a particular range.
i have the following code
Viewer1.ReportSource = Application.StartupPath + "//Label.rpt";
How can I assign it a dataset which have the data of a particular range.
Gurus, I hope I am clear.
Need it urgently, as my client is waiting for this for a long time.
thanks
-jlo