none
Report problem RRS feed

  • Question

  • Hi All!

    I'm  a bit new in developing.

    I have made data application, all components written manually with Ado.net.classes. need to make report.

    I make form for report viewer see code bellow:

    and make a report file receipt.rdlc
    but I can not see any record at report.

    can anyone help me, and show mistakes and correct code?


     
    Code Snippet

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Windows.Forms;
    using System.Data.SqlClient;
    using Microsoft.Reporting;
    using Microsoft.Reporting.WinForms;

    namespace ado.net
    {
    public partial class Receipt : Form
    {
    string connectionString = MDIParent.conectionText;
    string procedureString = "dbo.receiptPrint";


    public Receipt()
    {
    InitializeComponent();
    }

    private void Receipt_Load(object sender, EventArgs e)
    {


    //this.reportViewer1.RefreshReport();
    SqlConnection connect = new SqlConnection(connectionString);
    SqlCommand printCommand = connect.CreateCommand();
    printCommand.CommandText = procedureString;
    printCommand.CommandType = CommandType.StoredProcedure;
    connect.Open();
    printCommand.ExecuteNonQuery();
    connect.Close();
    DataSet printDataSet = new DataSet();
    SqlDataAdapter printDataAdapter = new SqlDataAdapter();
    printDataAdapter.SelectCommand = printCommand;
    printDataAdapter.Fill(printDataSet,"receiptPrint");
    DataTable dt = printDataSet.Tables[0];
    LocalReport rep = reportViewer1.LocalReport;
    this.reportViewer1.LocalReport.ReportEmbeddedResource = "ado.net.receipt.rdlc";
    ReportDataSource prtRcpt = new ReportDataSource("printDataset_vw_reception_first(CU02)", printDataSet.Tables["vw_reception"]);
    reportViewer1.LocalReport.DataSources.Clear();
    reportViewer1.LocalReport.DataSources.Add(prtRcpt);


    this.reportViewer1.RefreshReport();
    }


    }
    }

    Monday, November 24, 2008 12:34 PM

Answers

  • If you want to use report viewer designer to define your report you must add dataset in your project (not programatically. If you want to use dynamically generated dataset you must also dynamically build report definition file (.rdlc). To bulid your report definition dynamically here is language specification http://www.microsoft.com/sql/technologies/reporting/rdlspec.mspx and here are examples http://www.gotreportviewer.com/ (on bottom of page - "Generate RDLC dynamically").
    everything is a matter of probability...
    • Marked as answer by Mirage_sk Tuesday, December 2, 2008 7:05 PM
    Tuesday, December 2, 2008 2:49 PM

All replies

  • LocalReport rep = reportViewer1.LocalReport;

    you declare that variable, but as far as I can tell you don't use it again.

    the name of your report file is a bit strange.


    are you receiving any errors?

    And does your screen show anything at all?



    Living my life at 123mph in 11.15 seconds
    Monday, November 24, 2008 3:42 PM
  •  Hi,

    no any error, report viewer generate blank report.  Thats all.

    about name - Solutin name is Ado.Net and namespace is Ado.net;
    I read that sorce must be a [namespace.filename].

    whetn I try to add component like text box to *.rdlc  file, and configure it, propery window shows "Report item not linked to a dataset."

    how can I write correct code?
    Monday, November 24, 2008 6:00 PM
  • Hi
       You said that report viewer generate blank report but have you add any fields or tables? Make proper DataSet in your project and then use it in report designer.
    everything is a matter of probability...
    Friday, November 28, 2008 1:29 PM
  • pen_2 said:

    Hi
       You said that report viewer generate blank report but have you add any fields or tables? Make proper DataSet in your project and then use it in report designer.


    everything is a matter of probability...



    how can I do it programmicaly?
    Tuesday, December 2, 2008 2:34 PM
  • If you want to use report viewer designer to define your report you must add dataset in your project (not programatically. If you want to use dynamically generated dataset you must also dynamically build report definition file (.rdlc). To bulid your report definition dynamically here is language specification http://www.microsoft.com/sql/technologies/reporting/rdlspec.mspx and here are examples http://www.gotreportviewer.com/ (on bottom of page - "Generate RDLC dynamically").
    everything is a matter of probability...
    • Marked as answer by Mirage_sk Tuesday, December 2, 2008 7:05 PM
    Tuesday, December 2, 2008 2:49 PM
  • pen_2 said:

    If you want to use report viewer designer to define your report you must add dataset in your project (not programatically. If you want to use dynamically generated dataset you must also dynamically build report definition file (.rdlc). To bulid your report definition dynamically here is language specification http://www.microsoft.com/sql/technologies/reporting/rdlspec.mspx and here are examples http://www.gotreportviewer.com/ (on bottom of page - "Generate RDLC dynamically").


    everything is a matter of probability...



    thanks, man, I will make the dataset with wizard and receive the needed report file
    Tuesday, December 2, 2008 7:04 PM