Click here to Skip to main content
15,881,882 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
SQL
I am creating Pdf file from dataset for first time i can create pdf but for the secnd time its giving me this error

here is my code

for first tim its going to rendercontrol and for the secnd time its giving me this error



C#
public void Email()
    {
        try
        {
            emaildata();
            string userMail = emailname + "@ksmc.med.sa";
            using (StringWriter sw = new StringWriter())
            {
                using (HtmlTextWriter hw = new HtmlTextWriter(sw))
                {
                    DetailsView1.RenderControl(hw);
                    StringReader sr = new StringReader(sw.ToString());
                    Document pdfDoc = new Document(PageSize.A4, 10f, 10f, 10f, 0f);
                    HTMLWorker htmlparser = new HTMLWorker(pdfDoc);
                    using (MemoryStream memoryStream = new MemoryStream())
                    {
                        PdfWriter.GetInstance(pdfDoc, memoryStream);
                        pdfDoc.Open();
                        htmlparser.Parse(sr);
                        pdfDoc.Close();
                        byte[] bytes = memoryStream.ToArray();
                        memoryStream.Close();
                     }
                 }
           }
        }
}


C#
public void emaildata()
   {
       SqlCommand cmnd = new SqlCommand("SELECT dbo.Tbl_TechRequest.R_RequestNumber, dbo.Tbl_TechRequest.R_name, FROM _TechRequest WHERE  (dbo.Tbl_TechRequest.R_RequestNumber" +
            "   =@R_RequestNumber)");
       cmnd.Connection = con;
       cmnd.Parameters.Add("@R_RequestNumber", SqlDbType.Int).Value = id;
       SqlDataAdapter da = new SqlDataAdapter(cmnd);

       da.Fill(ds);
       DetailsView1.DataSource = ds;
       DetailsView1.DataBind();
   }
Posted

1 solution

See the answer - The document has no pages[^].
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900