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);
//table.SpacingBefore = 20f;
cell.Colspan = 2;
table.AddCell(cell);
cell = PhraseCell(new Phrase(), PdfPCell.ALIGN_CENTER);
cell.Colspan = 2;
cell.PaddingBottom = 30f;
这是我的 C# 代码。当我尝试执行时,它会出现以下错误
我不知道我从哪里得到错误,是代码本身还是数据库。在某些情况下,此代码有效,但在某些情况下,它会给出以下错误。你能向我澄清错误吗?
如果我使用 dr.rows.length ..它不显示行关键字
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;
}
}
}
}
这是 Getdata 方法..以前我将 FID 作为字符串但现在转换为 varchar,我正在努力获得正确的答案,请帮助重建我的代码