on 02-07-2012 12:43 PM
Hi,
Now that I am correctly populating my dataset and report with the code below I have another need.
DataSet ds = new DataSet();
//ReportDocument rd = new ReportDocument();
//rd.Load("Payments.rpt");
HollandMHP.HollandMHPDataSet.LedgerDataTable ldt = new HollandMHP.HollandMHPDataSet.LedgerDataTable();
HollandMHP.HollandMHPDataSet.CustDataTable cdt = new HollandMHP.HollandMHPDataSet.CustDataTable();
HollandMHP.HollandMHPDataSetTableAdapters.CustTableAdapter custdat = new HollandMHP.HollandMHPDataSetTableAdapters.CustTableAdapter();
HollandMHP.HollandMHPDataSetTableAdapters.LedgerTableAdapter ledgdat = new HollandMHP.HollandMHPDataSetTableAdapters.LedgerTableAdapter();
custdat.Fill(cdt);
ledgdat.Fill(ldt);
ds.Tables.Add(cdt);
ds.Tables.Add(ldt);
//ds.Tables[0].Select("NextDue < '" + DateTime.Now.Date.ToString() + "'");
Payments1.SetDataSource(ds);
//crystalReportViewer1.ReportSource = rd;
Notice the comented code. This is an attempt to change the report in code so that I do not need to create a new report form for each of my reports. My goal is to load the daaset and report based on the specific report selected. Can someone help in this attempt?
Not sure I understand:
My goal is to load the daaset and report based on the specific report selected.
But, use a case statement? If statement?
Ludek
Follow us on Twitter http://twitter.com/SAPCRNetSup
Got Enhancement ideas? Try the [SAP Idea Place|https://ideas.sap.com/community/products_and_solutions/crystalreports]
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I guess that detail is a bit important. I have no problems using IF (since there are only two reports in this program) but I am having trouble with the correct code to load the dataset and report. As the report is designed it works with the Payments1 report loaded and saved in the screen. I want to chahge the dataset (which should be possible by uncommenting the SELECT code) and the report. The report load was attempted and failed. I believe that is the biggest issue that I am having.
Something like this?
Dim crRpt as new ReportDocument
.
'Some condition
.
crReportDocument.Load("C:\MyReport_A.rpt")
.
.
crReportDocument.SetDataSource(dataSet_A)
.
.
crReportDocument.Close
crReportDocument.Dispose
.
'Some condition
.
crReportDocument.Load("C:\MyReport_B.rpt")
.
.
crReportDocument.SetDataSource(dataSet_B)
.
.
crReportDocument.Close
crReportDocument.Dispose
- Ludek
Thanks. My final code is
DataSet ds = new DataSet();
DataRow[] fds;
ReportDocument rd = new ReportDocument();
if (Form1.selrpt == "Payments")
{
rd.Load("c:
Payments.rpt");
HollandMHP.HollandMHPDataSet.LedgerDataTable ldt = new HollandMHP.HollandMHPDataSet.LedgerDataTable();
HollandMHP.HollandMHPDataSet.CustDataTable cdt = new HollandMHP.HollandMHPDataSet.CustDataTable();
HollandMHP.HollandMHPDataSetTableAdapters.CustTableAdapter custdat = new HollandMHP.HollandMHPDataSetTableAdapters.CustTableAdapter();
HollandMHP.HollandMHPDataSetTableAdapters.LedgerTableAdapter ledgdat = new HollandMHP.HollandMHPDataSetTableAdapters.LedgerTableAdapter();
custdat.Fill(cdt);
ledgdat.Fill(ldt);
ds.Tables.Add(cdt);
ds.Tables.Add(ldt);
rd.SetDataSource(ds);
}
else
{
rd.Load("c:
LatePay.rpt");
HollandMHP.HollandMHPDataSet.CustDataTable cdt = new HollandMHP.HollandMHPDataSet.CustDataTable();
HollandMHP.HollandMHPDataSetTableAdapters.CustTableAdapter custdat = new HollandMHP.HollandMHPDataSetTableAdapters.CustTableAdapter();
custdat.Fill(cdt);
ds.Tables.Add(cdt);
fds = ds.Tables[0].Select("NextDue < '" + DateTime.Now.Date + "'");
rd.SetDataSource(fds);
}
crystalReportViewer1.ReportSource = rd;
User | Count |
---|---|
88 | |
23 | |
11 | |
9 | |
8 | |
5 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.