Bhavesh Vankar

Bhavesh Vankar

  • 753
  • 1.2k
  • 89.4k

print current record in crystal report without print preview

Jan 27 2021 7:53 AM
i have used below code to print current record but getting error "Report Load Faild" kindly guide me where is mistake. i am loading this method in save button after ExcecuteNonQuery.
 
  1. private void PrintReport()  
  2. {  
  3.     SqlConnection con = new SqlConnection(this.con);  
  4.     SqlDataAdapter sda = new SqlDataAdapter("Select * from S_TEST Where S_ID='" + TxtAutovID.Text + "'", con);  
  5.     DataSet ds = new DataSet();  
  6.     sda.Fill(ds);  
  7.     ReportDocument rpd = new ReportDocument();  
  8.     rpd.Load(Server.MapPath("~/studentpass.rpt"));  
  9.     rpd.SetDataSource(ds.Tables[0]);  
  10.     CrptViewer.ReportSource = rpd;  
  11.     rpd.PrintToPrinter(1, false, 0, 0);  
  12. }  
 

Answers (1)