Sir, thx for your tutorial, but i have a problem when i try to use the tool ReportViewer on the Windows Form, it doesn't show me anything when i put it on the win form. What should I do to solve it?
What should I Do i can't load my form po because of this 'The primary reference could not be resolved because it was against the .NETFramework, Version=v4. 5". This js a higher version than the currently targeted framework ". NETFramework, Version =v4. 5. please🙏 answer. thank you so much.
Sir i am getting issue (cannot create data reader for dataset 'DataSet1') while my code is correct as per your tutorial coding. full code is below using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Data.SqlClient; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using Microsoft.Reporting.WinForms; namespace POS_Sales { public partial class Receipt : Form { SqlConnection cn = new SqlConnection(); SqlCommand cm = new SqlCommand(); DBConnect dbcon = new DBConnect(); SqlDataReader dr; string store; string address; Cashier cashier; public Receipt(Cashier cash) { InitializeComponent(); cn = new SqlConnection(dbcon.myConnection()); cashier = cash; LoadStore(); } public void LoadStore() { cn.Open(); cm = new SqlCommand("SELECT * FROM tbStore", cn); dr = cm.ExecuteReader(); dr.Read(); if(dr.HasRows) { store = dr["store"].ToString(); address = dr["address"].ToString(); } dr.Close(); cn.Close(); } private void Receipt_Load(object sender, EventArgs e) { this.reportViewer1.RefreshReport(); } public void LoadReceipt(string pcash, string pchange) { ReportDataSource rptDataSourece; try { this.reportViewer1.LocalReport.ReportPath = Application.StartupPath + @"\Reports ptReceipt.rdlc"; this.reportViewer1.LocalReport.DataSources.Clear(); DataSet1 ds = new DataSet1(); SqlDataAdapter da = new SqlDataAdapter(); cn.Open(); da.SelectCommand = new SqlCommand("SELECT c.id, c.transno, c.pcode, c.price, c.qty, c.disc, c.total, c.sdate, c.status, p.pdesc FROM tbCart1 AS c INNER JOIN tbProduct AS p ON p.pcode=c.pcode WHERE c.transno LIKE '"+cashier.lblTranNo.Text+"'",cn); da.Fill(ds.Tables["dtReceipt"]); cn.Close(); ReportParameter pVatable = new ReportParameter("pVatable", cashier.lblVatable.Text); ReportParameter pVat = new ReportParameter("pVat", cashier.lblVat.Text); ReportParameter pDiscount = new ReportParameter("pDiscount", cashier.lblDiscount.Text); ReportParameter pTotal = new ReportParameter("pTotal", cashier.lblDisplayTotal.Text); ReportParameter pCash = new ReportParameter("pCash", pcash); ReportParameter pChange = new ReportParameter("pChange", pchange); ReportParameter pStore = new ReportParameter("pStore", store); ReportParameter pAddress = new ReportParameter("pAddress", address); ReportParameter pTransaction = new ReportParameter("pTransaction", "Invoice #: " + cashier.lblTranNo.Text); ReportParameter pCashier = new ReportParameter("pCashier", cashier.lblUsername.Text); reportViewer1.LocalReport.SetParameters(pVatable); reportViewer1.LocalReport.SetParameters(pVat); reportViewer1.LocalReport.SetParameters(pDiscount); reportViewer1.LocalReport.SetParameters(pTotal); reportViewer1.LocalReport.SetParameters(pCash); reportViewer1.LocalReport.SetParameters(pChange); reportViewer1.LocalReport.SetParameters(pStore); reportViewer1.LocalReport.SetParameters(pAddress); reportViewer1.LocalReport.SetParameters(pTransaction); reportViewer1.LocalReport.SetParameters(pCashier); rptDataSourece = new ReportDataSource("DataSet1", ds.Tables["dtSold"]); reportViewer1.LocalReport.DataSources.Add(rptDataSourece); reportViewer1.SetDisplayMode(Microsoft.Reporting.WinForms.DisplayMode.PrintLayout); reportViewer1.ZoomMode = ZoomMode.Percent; reportViewer1.ZoomPercent = 30; } catch(Exception ex) { cn.Close(); MessageBox.Show(ex.Message); } } private void Receipt_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Escape) { this.Dispose(); } } } }
@@Mdemy yes sir .... thank you so much for ur response there is one error in ur code rptDataSourece = new ReportDataSource("DataSet1", ds.Tables["dtSold"]); in ds.Tables{"dtSold"]) there must be dtReceipt
Hello, thx for your tutorial, i learn SO MUCH... But i have a problem, im doing this with VSCode 2022 and when i need to print i have an error: no se puede cargar el archivo o ensamblado 'microsoft.reportviewer.common (can not open the file or assemble microsoft.report.viewer.common) V15.0 The definition of ensambler do not match with re reference. 0x80131040) Thanks for all!
Sir, thx for your tutorial, but i have a problem when i try to use the tool ReportViewer on the Windows Form, it doesn't show me anything when i put it on the win form. What should I do to solve it?
What should I Do i can't load my form po because of this 'The primary reference could not be resolved because it was against the .NETFramework, Version=v4. 5". This js a higher version than the currently targeted framework ". NETFramework, Version =v4. 5. please🙏 answer. thank you so much.
Sir The Database Is Not Working When I Open Plz Help Me Sir and send me the source code
i will send you after this tutorial finish
@@Mdemy Thanks To Mdemy TH-cam Totriols This Is The Best Channel Subscribe and shre to this channel
th-cam.com/video/tDAUNikOylg/w-d-xo.html
Sir i am getting issue (cannot create data reader for dataset 'DataSet1') while my code is correct as per your tutorial coding. full code is below
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Microsoft.Reporting.WinForms;
namespace POS_Sales
{
public partial class Receipt : Form
{
SqlConnection cn = new SqlConnection();
SqlCommand cm = new SqlCommand();
DBConnect dbcon = new DBConnect();
SqlDataReader dr;
string store;
string address;
Cashier cashier;
public Receipt(Cashier cash)
{
InitializeComponent();
cn = new SqlConnection(dbcon.myConnection());
cashier = cash;
LoadStore();
}
public void LoadStore()
{
cn.Open();
cm = new SqlCommand("SELECT * FROM tbStore", cn);
dr = cm.ExecuteReader();
dr.Read();
if(dr.HasRows)
{
store = dr["store"].ToString();
address = dr["address"].ToString();
}
dr.Close();
cn.Close();
}
private void Receipt_Load(object sender, EventArgs e)
{
this.reportViewer1.RefreshReport();
}
public void LoadReceipt(string pcash, string pchange)
{
ReportDataSource rptDataSourece;
try
{
this.reportViewer1.LocalReport.ReportPath = Application.StartupPath + @"\Reports
ptReceipt.rdlc";
this.reportViewer1.LocalReport.DataSources.Clear();
DataSet1 ds = new DataSet1();
SqlDataAdapter da = new SqlDataAdapter();
cn.Open();
da.SelectCommand = new SqlCommand("SELECT c.id, c.transno, c.pcode, c.price, c.qty, c.disc, c.total, c.sdate, c.status, p.pdesc FROM tbCart1 AS c INNER JOIN tbProduct AS p ON p.pcode=c.pcode WHERE c.transno LIKE '"+cashier.lblTranNo.Text+"'",cn);
da.Fill(ds.Tables["dtReceipt"]);
cn.Close();
ReportParameter pVatable = new ReportParameter("pVatable", cashier.lblVatable.Text);
ReportParameter pVat = new ReportParameter("pVat", cashier.lblVat.Text);
ReportParameter pDiscount = new ReportParameter("pDiscount", cashier.lblDiscount.Text);
ReportParameter pTotal = new ReportParameter("pTotal", cashier.lblDisplayTotal.Text);
ReportParameter pCash = new ReportParameter("pCash", pcash);
ReportParameter pChange = new ReportParameter("pChange", pchange);
ReportParameter pStore = new ReportParameter("pStore", store);
ReportParameter pAddress = new ReportParameter("pAddress", address);
ReportParameter pTransaction = new ReportParameter("pTransaction", "Invoice #: " + cashier.lblTranNo.Text);
ReportParameter pCashier = new ReportParameter("pCashier", cashier.lblUsername.Text);
reportViewer1.LocalReport.SetParameters(pVatable);
reportViewer1.LocalReport.SetParameters(pVat);
reportViewer1.LocalReport.SetParameters(pDiscount);
reportViewer1.LocalReport.SetParameters(pTotal);
reportViewer1.LocalReport.SetParameters(pCash);
reportViewer1.LocalReport.SetParameters(pChange);
reportViewer1.LocalReport.SetParameters(pStore);
reportViewer1.LocalReport.SetParameters(pAddress);
reportViewer1.LocalReport.SetParameters(pTransaction);
reportViewer1.LocalReport.SetParameters(pCashier);
rptDataSourece = new ReportDataSource("DataSet1", ds.Tables["dtSold"]);
reportViewer1.LocalReport.DataSources.Add(rptDataSourece);
reportViewer1.SetDisplayMode(Microsoft.Reporting.WinForms.DisplayMode.PrintLayout);
reportViewer1.ZoomMode = ZoomMode.Percent;
reportViewer1.ZoomPercent = 30;
}
catch(Exception ex)
{
cn.Close();
MessageBox.Show(ex.Message);
}
}
private void Receipt_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Escape)
{
this.Dispose();
}
}
}
}
you add DataTable in DataSet1
@@Mdemy i have added that too "dtReceipt"
hey are u okay
@@Mdemy yes sir .... thank you so much for ur response there is one error in ur code
rptDataSourece = new ReportDataSource("DataSet1", ds.Tables["dtSold"]);
in ds.Tables{"dtSold"]) there must be dtReceipt
good job bro
Hello, thx for your tutorial, i learn SO MUCH... But i have a problem, im doing this with VSCode 2022 and when i need to print i have an error: no se puede cargar el archivo o ensamblado 'microsoft.reportviewer.common (can not open the file or assemble microsoft.report.viewer.common) V15.0 The definition of ensambler do not match with re reference. 0x80131040) Thanks for all!
Me too, have you solve it?
@@luxymen6998 Nope, sorry :C
Try to delete Microsoft.ReportViewer.Common package. I don't know why, but It worked for me