Reputation: 839
I have 2 tables in Microsoft Access 2007.
The table name "BillDetail" and "BillMaster"
Fields contained in BillMaster is : BillNO, BillType, Dt, PartyName
Fields contained in BillDetail table is : BillNo(Ref) Serial No. Desc HSNCode Qty Rate.
I need to fetch data from both tables. The Master Record should be displayed in header and all the related items should be displayed in tabular form. And I finally want to print these information as a bill.
My basic need is not to use the crystal reports. I searched a lot over internet and found a solution that to use the ReportViewer Control. But unfortunately I don't know how to build report using this control. Please help me to generate the report or post some links of tutorial.
Please help. I am totally new to Windows Application Development.
Upvotes: 0
Views: 22261
Reputation:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Configuration;
using System.Data.SqlClient;
using Microsoft.Reporting.WinForms;
namespace RDLC
{
public partial class RD : Form
{
public RD()
{
InitializeComponent();
}
private void RD_Load(object sender, EventArgs e)
{
DataTable dt = new DataTable();
dt = GetData("select * from tbl_Admission_Form");
ReportDataSource datasource = new ReportDataSource("DataSet1", dt);
reportViewer1.LocalReport.DataSources.Clear();
reportViewer1.ProcessingMode = ProcessingMode.Local;
reportViewer1.LocalReport.ReportEmbeddedResource = "RDLC.Report1.rdlc";
reportViewer1.LocalReport.DataSources.Add(datasource);
//this.reportViewer1.RefreshReport();
this.reportViewer1.RefreshReport();
}
private DataTable GetData(string query)
{
string conString = ConfigurationManager.ConnectionStrings["constr"].ConnectionString;
SqlConnection con = new SqlConnection(conString);
con.Open();
SqlCommand cmd = new SqlCommand(query);
cmd.Connection = con;
cmd.ExecuteNonQuery();
cmd.Dispose();
SqlDataAdapter sda = new SqlDataAdapter(cmd);
DataTable ds = new DataTable();
sda.Fill(ds);
return ds;
}
}
}
Upvotes: 0
Reputation: 11
Here you can find an example,How to Generate RDLC Reports in C# with Code Example...
http://www.dotnetsharepoint.com/2013/08/how-to-create-rdlc-report-in-c-windows.html#.UgCO6pKfjwg
Upvotes: 0
Reputation: 10712
The report viewer control is capable of rendering reports that are defined in rdl
or rdlc
files.
rdl
stands for "Report definition language" and the "C" stands for "Client Reports" that is vs. "Server Reports"
so if you don't have a reporting server installed you would probably be best using rdlc
and attaching your Access 2007 DB as the datasource for your report.
here are several tutorials for creating rdlc
reports files and using report viewer control:
CodeProject - How to connect a report i.e. rdlc file with the project form.
Beginner's guide for creating standalone .rdlc reports with ssrs
Upvotes: 2