Problem with Report Viewer in VS2005

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • =?Utf-8?B?Unlhbg==?=

    #1

    Problem with Report Viewer in VS2005

    I have the following code which compiles fine but the data set (ds) returns 0
    count and the rptViewer1 is blank.
    If I change the name of the rdlc file (rep.ReportPath = "Customer.rdlc" ;) to
    something else which does not exist; this code still compiles and brings up
    the empty report. What am I doing wrong?

    using System;
    using System.Collecti ons.Generic;
    using System.Componen tModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Windows. Forms;
    using System.Data.Ole Db;

    namespace WindowsApplicat ion1
    {
    public partial class frmRptView : Form
    {
    public frmRptView()
    {
    InitializeCompo nent();
    }

    private void frmRptView_Load (object sender, EventArgs e)
    {
    FindAll();
    }

    public void FindAll()
    {
    this.reportView er1.ProcessingM ode =
    Microsoft.Repor ting.WinForms.P rocessingMode.L ocal;
    Microsoft.Repor ting.WinForms.L ocalReport rep =
    reportViewer1.L ocalReport;
    rep.ReportPath = "Customer.rdlc" ;
    DataSet ds = GetSalesDataFul l();
    Microsoft.Repor ting.WinForms.R eportDataSource dsMaintenanceDS =
    new Microsoft.Repor ting.WinForms.R eportDataSource ();

    dsMaintenanceDS .Name = "Customer";
    dsMaintenanceDS .Value = ds.Tables["Customer"];
    rep.DataSources .Clear();

    rep.DataSources .Add(dsMaintena nceDS);
    rep.Refresh();
    }

    private DataSet GetSalesDataFul l()
    {
    OleDbConnection Myconnection = null;
    DataSet ds = new DataSet();

    Myconnection = new
    OleDbConnection (@"Provider=Mic rosoft.Jet.OLED B.4.0; User Id=; Password=; Data
    Source=C:\\Cust omer.mdb");
    Myconnection.Op en();

    string sqlSalesData = @"SELECT * FROM Customer ";
    OleDbCommand command = new OleDbCommand(sq lSalesData,
    Myconnection);
    OleDbDataAdapte r salesOrderAdapt er = new
    OleDbDataAdapte r(command);
    salesOrderAdapt er.Fill(ds, "Customer") ;
    salesOrderAdapt er.Dispose();
    command.Dispose ();
    return ds;
    }

    }
    }

Working...