0

I Am developing a resturant windows application in c#.net and I print receipt of the ordered food bt rdlc on c#.net. now I want to print reciept So quickly .without opening another form to show reportViewer .I used below code But It didnot worked Please help me code :

  ReportDataSet ds = new ReportDataSet();
            ReportViewer rptViewer = new ReportViewer();
            rptViewer.LocalReport.DataSources.Clear();
            SqlDataAdapter cmd = new SqlDataAdapter("SelectForoshByNobat", new SqlConnection(DBSetting.DBconstr));
            cmd.SelectCommand.CommandType = CommandType.StoredProcedure;
            cmd.SelectCommand.Parameters.AddWithValue("@nobat", textBox1.Text);
            ds.Tables[0].Clear();
            cmd.Fill(ds.Tables[0]);
            rptViewer.LocalReport.DataSources.Add(new ReportDataSource("DataTable1", ds.Tables[0]));
            rptViewer.LocalReport.ReportEmbeddedResource = "FishReport.rdlc";
            rptViewer.SetDisplayMode(DisplayMode.PrintLayout);
            rptViewer.ZoomMode = ZoomMode.FullPage;
            printDialog1.Document = printDocument1;
            if (printDialog1.ShowDialog() == DialogResult.OK)
                printDocument1.Print();
  • Mr Aghaei .I reviewed your Marked answer .it is different.Because I am using Rdlc not crystalReport.Please Unmarke this question – user6641321 Oct 27 '16 at 14:55
  • The question is obviously a duplicate. Please read the answer carefully. The answer shared 2 solutions for you. Have you read the answer? Probably you just read the question! – Reza Aghaei Oct 27 '16 at 17:22
  • Use first option. I checked it again and it works properly. – Reza Aghaei Oct 27 '16 at 17:48

0 Answers0