Skip to Content
author's profile photo Former Member
Former Member

C# VS2008 Change Report And Data Set

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?

Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • Best Answer
    Posted on Feb 07, 2012 at 02:10 PM

    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]

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Ludek Uher

      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;

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.