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..を使用すると、rowキーワードが表示されません
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 に変換されています。正しい答えを得るのに苦労しています。コードの再構築を手伝ってください