title: Application Freezes While Printing in C#.net
body: <p>In my C# application, everything becomes frozen at the time of printing when the software runs in the network and multiple computers access the common database. </p>
  
  <p>It doesn't always happen.</p>
  
  <p>This is how I did the print job:</p>
  
  <ol>
  <li>I include a dataset of my database in my project</li>
  <li>Then I perform all print work from that dataset. I don't create ODBC connection for printing</li>
  </ol>
  
  <p>Here is the code for printing:</p>
  
  <pre><code>using (ReportDocument rptDc = new ReportDocument())
  {
      using (DataSet HospDataSet = new HospitalDataSet())
      {
          DataTable Dt = new DataTable();
          Dt.Columns.Add("Sr", typeof(int));
          Dt.Columns.Add("Query", typeof(string));
          Dt.Rows.Add(1, "select * from DG_Receipt where Id = " + SetId + "");
          Dt.Rows.Add(2, "select * from DG_Receipt_Detail where IdFk = " + SetId + " order by Sr");
          Dt.Rows.Add(3, "select * from DG_RefundMain where BillVouNo = (Select VouNo from DG_Receipt where Id = " + SetId + ")");
          Dt.Rows.Add(4, "select * from DG_Identity");
  
          using (DataSet Ds = GetPrintDetails(Dt, Con))
          {
              HospDataSet.Tables["DG_Receipt"].Merge(Ds.Tables[0]);
              HospDataSet.Tables["DG_Receipt_Detail"].Merge(Ds.Tables[1]);
              HospDataSet.Tables["DG_RefundMain"].Merge(Ds.Tables[2]);
              HospDataSet.Tables["DG_Identity"].Merge(Ds.Tables[3]);
  
              ReportPath = Environment.CurrentDirectory + "\\Reports_DG\\rptDG_Receipt.rpt";
              rptDc.Load(ReportPath);
  
              rptDc.SetDataSource(HospDataSet);
              rpvHospitalReportViewer.ReportSource = rptDc;
              rptDc.PrintOptions.PrinterName = SetPrinterName;
              rptDc.PrintToPrinter(SetPrintCopies, false, 0, 0);
          }
      }
  }
  </code></pre>
  
  <p>Please guys help me. What I am doing wrong here. It's a very serious issue for me.</p>
  
  <p><strong>Edit</strong>: I think it happens when the print job execute from multiple computers at the same time.</p>