Advertisement
how to create rdlc report in c# windows application
See my Previous Article for that Form1.I am designing my screen having,Combo Box, Two DateTimePicker and Button for Generating report.
How to Page number in rdlc reports
How to add no data found message in rdlc report
How to Page number in rdlc reports
How to add no data found message in rdlc report
My Out Put looks like this,By default I
will display All information.
If we select the combo box options and
click on Generate Button,It will Show the Out Put Based on My
Requirement
I Designed the Report Form UI looks like this.
I Design database looks like this.
Now I am creating the stored procedure
to generate reports based upon date selection.
See my Previous Article where we can select existing stored procedure.
USE [chinnu] GO /****** Object: StoredProcedure [dbo].[SP_GenerateReport] Script Date: 08/05/2013 04:15:41 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO create procedure [dbo].[SP_GenerateReport] ( @StartDate DateTime ,@EndDate DateTime ) as BEGIN SELECT EmpId,Convert(varchar,CreatedDate,101) As CreatedDate ,EmpName,EmpAddress FROM Employee WHERE Convert(varchar,CreatedDate,101) between @StartDate and @EndDate END GO
Finally my solution looks like this.
Now write the code in Form1.cs
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.Data.SqlClient; namespace RdlcReports { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { ddlperiod.Items.Add("All"); ddlperiod.Items.Add("Today"); ddlperiod.Items.Add("Yesterday"); ddlperiod.Text = "All"; // TODO: This line of code loads data into the 'DataSet1.SP_GenerateReport' table. You can move, or remove it, as needed. //this.SP_GenerateReportTableAdapter.Fill(this.DataSet1.SP_GenerateReport); this.SP_GenerateReportBindingSource.DataSource = ReportData(); ReportData(); this.reportViewer1.RefreshReport(); } public static DataTable ReportData() { DataTable DatTab = new DataTable(); try { SqlConnection con = new SqlConnection("Data Source=DotNetSharePoint;Initial Catalog=chinnu;User ID=sa;Password = Admin1234;" ); con.Open(); if (true) { con.Close(); SqlCommand cmd = new SqlCommand("SELECT EmpId,Convert(varchar,CreatedDate,101) As CreatedDate ,EmpName,EmpAddress FROM Employee", con); //cmd.CommandType = CommandType.StoredProcedure; SqlDataAdapter adap = new SqlDataAdapter(cmd); adap.Fill(DatTab); } else { } con.Close(); } catch (Exception ex) { throw ex; } return DatTab; } private void btnReprt_Click(object sender, EventArgs e) { string Fdate = ddlstartdate.Text; string Ldate = ddlenddate.Text; DataTable DatTab = new DataTable(); SqlConnection con = new SqlConnection("Data Source=DotNetSharePoint;Initial Catalog=chinnu;User ID=sa;Password = Admin1234;"); con.Open(); if (ddlperiod.Text == "All") { SqlCommand cmd = new SqlCommand("SELECT EmpId,Convert(varchar,CreatedDate,101) As CreatedDate ,EmpName,EmpAddress FROM Employee", con); SqlDataAdapter adap = new SqlDataAdapter(cmd); adap.Fill(DatTab); } else { using (SqlCommand cmd = new SqlCommand("SP_GenerateReport", con)) { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add(new SqlParameter("StartDate", SqlDbType.DateTime)).Value = Convert.ToDateTime(Fdate).ToShortDateString(); cmd.Parameters.Add(new SqlParameter("EndDate", SqlDbType.DateTime)).Value = Convert.ToDateTime(Ldate).ToShortDateString(); cmd.ExecuteNonQuery(); SqlDataAdapter da = new SqlDataAdapter(cmd); da.Fill(DatTab); } } con.Close(); this.SP_GenerateReportBindingSource.DataSource = DatTab; this.reportViewer1.RefreshReport(); } private void ddlperiod_SelectedIndexChanged(object sender, EventArgs e) { var toDate = DateTime.Now; var fromDate = DateTime.Today; switch (ddlperiod.Text) { case "Today": fromDate = toDate; break; case "Yesterday": fromDate = toDate.AddDays(-1); toDate = toDate.AddDays(-1); break; default: break; } ddlstartdate.Text = fromDate.ToShortDateString(); ddlenddate.Text = toDate.ToShortDateString(); } } }
Now Add AppConfig for DataBase Connection.
After Completing the Steps,Press F5.
OutPut:
Now Select Today Date Click on Generate Report,It will shows today's Information
Hi, e i am newbi and i do not know what SP_GenerateReportBindingSource, whould you please tell me what controls is that, thnks a lot
ReplyDeleteSP_GenerateReportBindingSource same issue
ReplyDeleteSIIII DIOOOOO!
ReplyDeleteThis article gives the light in which we can observe the reality. This is very nice one and gives indepth information. Thanks for this nice article. Search Bar Firefox 57 Quantum addon
ReplyDeleteToday, I went to the beach with my children. I found a seashell and gave it to my 4 year old daughter and said "You can hear the ocean if you put this to your ear." She placed the shell to her ear and screamed. There was a hermit crab inside and it pinched her ear. She never wants to go back! LOL I know this is completely off topic, but I had to tell someone! Visite site: How To Lock Files When Nobody Else Will
ReplyDeleteWow what a Great Information about World Day its exceptionally pleasant educational post. a debt of gratitude is in order for the post. Roblox Download Android Version for free
ReplyDeleteI'm happy to see the considerable subtle element here!. Download TubeMate APK Free
ReplyDeleteJust pure brilliance from you here. I have never expected something less than this from you and you have not disappointed me at all. I suppose you will keep the quality work going on. TubeMate APK iPhone Download
ReplyDeleteVery awesome!!! When I seek for this I found this website at the top of all blogs in search engine. Andriod Download
ReplyDeleteGood to become visiting your weblog again, it has been months for me. Nicely this article that i've been waited for so long. I will need this post to total my assignment in the college, and it has exact same topic together with your write-up. Thanks, good share. windows 10 bsod
ReplyDeleteAmazing post to learn a lot in just a simple way. You have made it easier with wonderful explanation. Your post ends the search of many users for rdlc creation in C. I really appreciate it. Thank you.
ReplyDeleteHello How can I generate report from csv file
ReplyDeleteAndroid as an operating system has had some wonderful success over the last few years. For some time, Android manufacturers took a back seat to Apple; Android was good, but iOS was better, the critics said. Over the last few years, Android's success has critics seeing the Apple enemy in a whole new light, with some suggesting that the future of the smartphone industry lies with Android manufacturers and not with the Apple Corporation - a company that many once thought was invincible and beyond fail. Genuine app for Sweatcoin
ReplyDeletephòng vé Eva Air tại hà nội
ReplyDeleteJapan Airlines đổi vé miá»…n phÃ
China Airlines mua thêm hà nh lý
Large windows create a seamless transition between indoor and outdoor spaces. Affordable Window Repair
ReplyDeleteMy water heater is a lifesaver in the winter! water heater replacement malden
ReplyDeleteUÅŸak
ReplyDeleteAnkara
Adıyaman
Hatay
Şırnak
U0P
"I'm so grateful for my tankless water heater; it's been a game-changer for my energy bills." water heater replacement englewood
ReplyDeleteÄ°stanbul Lojistik
ReplyDeleteZonguldak Lojistik
Konya Lojistik
Ağrı Lojistik
Ordu Lojistik
QR7W
33E9A
ReplyDeleteAntalya Evden Eve Nakliyat
Ankara Lojistik
Yalova Lojistik
Amasya Lojistik
Ordu Parça Eşya Taşıma
0EE6B
ReplyDeleteMuğla Şehir İçi Nakliyat
Aydın Lojistik
Muğla Şehirler Arası Nakliyat
Ä°zmir Evden Eve Nakliyat
Rize Şehirler Arası Nakliyat
Kütahya Lojistik
Nevşehir Parça Eşya Taşıma
Aksaray Lojistik
Telcoin Coin Hangi Borsada
CCF86
ReplyDeleteurfa mobil sohbet bedava
bayburt telefonda sohbet
malatya görüntülü sohbet ücretsiz
Gümüşhane Görüntülü Sohbet Canlı
ordu sohbet odaları
kızlarla rastgele sohbet
Kocaeli Görüntülü Canlı Sohbet
adıyaman rastgele sohbet odaları
elazığ telefonda canlı sohbet
098A4
ReplyDeleteçankırı mobil sohbet chat
Bolu Görüntülü Sohbet Sitesi
parasız görüntülü sohbet
Sakarya Canlı Sohbet Odaları
sinop sohbet odaları
bolu sohbet uygulamaları
bingöl canlı görüntülü sohbet uygulamaları
görüntülü sohbet kadınlarla
görüntülü sohbet
B0794
ReplyDeleteprobit
probit
toptan sabun
bitcoin nasıl üretilir
referans kodu
canlı sohbet ücretsiz
bitcoin ne zaman çıktı
okex
4g mobil
B90BD
ReplyDeletefiltre kağıdı
bitget
binance
okex
bitget
bingx
gate io
kripto para nereden alınır
okex
49345
ReplyDeletekripto para nereden alınır
mexc
kripto telegram
canlı sohbet
bitexen
telegram kripto kanalları
referans kimligi nedir
bitcoin ne zaman çıktı
gate io
51655
ReplyDeletebtcturk
bitrue
kripto ne demek
bybit
bybit
papaya meyvesi
kripto para nasıl alınır
kraken
kraken
E65DE
ReplyDeletegörüntülü show
C8C18
ReplyDeletegörüntülü şov
37FBC
ReplyDeletegörüntülü şov