Jes Sie

Jes Sie

  • 743
  • 1.2k
  • 279.9k

Printing RDLC Report Using Asp.net C#

Aug 10 2019 2:44 AM
Hello everyone, hope someone can give me the correct code. 
 
I am trying to print a RDLC report without preview. Below is my code but does not work. The error says "Exception Details: System.NotSupportedException: The given path's format is not supported."
 
  1. protected void PrintPos(object sender, EventArgs e)  
  2.         {  
  3.             string sql = "spGet_SalesDetails_A4Printing";  
  4.             var dt = GetDataTable(sql);  
  5.             LocalReport report = new LocalReport();  
  6.             string path = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase);  
  7.             string fullpath = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase).Remove(path.Length - 4) + @"\PosPrinting\PrintingPos.rdlc";  
  8.             report.ReportPath = fullpath;  
  9.             report.DataSources.Add(new ReportDataSource("dsProduct", dt));  
  10.             int printQty = 2;  
  11.             for(int i = 0; i < printQty; i++)  
  12.             {  
  13.                 PrintToPrinter(report);  
  14.             }  
  15.         }  
I am following this post: https://ashproghelp.blogspot.com/2017/01/how-to-print-directly-without-showing.html 

Answers (3)