DataRow dr = GetData("select * from Personal_det where Fid='" + va+"'").Rows[0]; Document doc = new Document(PageSize.A4, 88f, 88f, 10f, 10f); Font NormalFont = FontFactory.GetFont("Arial", 12, Font.NORMAL, BaseColor.BLACK); using (System.IO.MemoryStream m = new System.IO.MemoryStream()) { PdfWriter w = PdfWriter.GetInstance(doc, m); Phrase phrase = null; PdfPCell cell = null; PdfPTable table = null; BaseColor color = null; Paragraph para = null; Font times = null; BaseFont bfTimes = null; doc.Open(); table = new PdfPTable(2); cell = PhraseCell(new Phrase("Faculty Profile", FontFactory.GetFont("Arial", 12, Font.UNDERLINE, BaseColor.BLACK)), PdfPCell.ALIGN_CENTER);
This is my C # code. When I try to execute it, you get the following error:
I donβt know where I get the error from: this is from the code itself or the database. In some cases, this code works, but for some instance it will give the following error. Can you clarify my mistake.?
If I use dr.rows.length..It does not show the row keyword
private DataTable GetData(string query) { string conString = ConfigurationManager.ConnectionStrings["ProjectConnectionString"].ConnectionString; SqlCommand cmd = new SqlCommand(query); using (SqlConnection cn = new SqlConnection(conString)) { using (SqlDataAdapter da = new SqlDataAdapter()) { cmd.Connection = cn; da.SelectCommand = cmd; using (DataTable dt = new DataTable()) { da.Fill(dt); return dt; } } } }
This is the Getdata method. Previously, I had FID as a string, but now converted to varchar, I'm struggling to get the correct answer, please help restore my code
user2660112
source share