C# 在后台用 table 创建表,怎么把数据库中的数据导入表格中
哪位大神帮下忙。谢谢
这是我自己写的代码,但是数据没有导入成功,只有这样的一个表头
<tr><td>学生姓名</td><td>学生学号</td><td>性别</td><td>就业方式</td><td>招聘职位</td><td>备注</td><td>就业单位名称</td></tr>
数据没有,还有哪里没写完的吗?求教高手
protected void pub(string id, int pubFlag)
{
/* string strtb = "SELECT d.学生姓名,a.学生学号,d.性别,a.就业方式,c.职位名称" +
"a.备注,b.就业单位名称 " +
" FROM Student_baseinfo AS d,zj_netinfoEx AS a INNER JOIN zj_job_infoEx AS b " +
" ON a.招聘信息编号 = b.招聘信息编号 " +
" LEFT OUTER JOIN zj_job AS c ON a.招聘岗位编号 = c.职位编号 " +
" WHERE a.valid != 0 AND b.valid!=0 AND a.学生学号 = d.学生学号 AND a.招聘信息编号='" + id + "'";*/
string str = "SELECT d.学生姓名,d.性别,a.学生学号,a.就业方式,a.备注," +
"a.应聘信息编号,b.招聘信息编号,b.就业单位名称,b.招聘标题,c.职位名称 " +
" FROM Student_baseinfo AS d,zj_netinfoEx AS a INNER JOIN zj_job_infoEx AS b " +
" ON a.招聘信息编号 = b.招聘信息编号 " +
" LEFT OUTER JOIN zj_job AS c ON a.招聘岗位编号 = c.职位编号 " +
" WHERE a.valid != 0 AND b.valid!=0 AND a.学生学号 = d.学生学号 AND a.招聘信息编号='" + id + "'";
string no, strJob, time;
string head;
int i;
DataRow d;
DataSet ds;
time = DateTime.Now.ToString();
no = objCom.GetMaxNo("00000000000", "编号", "content", ""); //发布信息的id
string toAdd = "<table border= \"1\" style=\"text-align:center;\"><tr><td>学生姓名</td><td>学生学号</td><td>性别</td><td>就业方式</td><td>招聘职位</td><td>备注</td><td>就业单位名称</td></tr>";
if (pubFlag == 1)
{
head = "<h1>录用结果:</h1>";
ds = objCom.GetDSCommon(str, "zj_netinfoEx");
for (i = 0; i < ds.Tables[0].Rows.Count; i++)
{
d = ds.Tables[0].Rows[i];
strJob = d["职位名称"] == null ? "待定" : d["职位名称"].ToString().Trim();
toAdd += "<tr><td>" + d["学生姓名"] + "</td><td>" + d["学生学号"] + "</td><td>" + d["性别"] + "</td><td>" + d["就业方式"] + "</td><td>" + strJob;
toAdd += "</td><td>" + d["备注"] + "</td><td>" + d["就业单位名称"] + "</td></tr>";
}
string s = "INSERT INTO content(编号,栏目编号,标题,日期,作者,上传日期,内容,审核,审核人,审核日期,隐藏,内容类型,招聘信息编号) VALUES('" +
no + "','0405','录用结果发布','" +
time + "','招生就业办','" + time + "','" +
head + toAdd + "','01','系统','" +
time + "','显示','内容','y" + id + "')";
objCom.excsql(s);
}
if (pubFlag == 0)
{
head = "<h1>撤销录用结果:</h1>";
ds = objCom.GetDSCommon(str, "zj_netinfoEx");
for (i = 0; i < ds.Tables[0].Rows.Count; i++)
{
d = ds.Tables[0].Rows[i];
strJob = d["职位名称"] == null ? "待定" : d["职位名称"].ToString().Trim();
toAdd += "<tr><td>" + d["学生姓名"] + "</td><td>" + d["学生学号"] + "</td><td>" + d["性别"] + "</td><td>" + d["就业方式"] + "</td><td>" + strJob;
toAdd += "</td><td>" + d["备注"] + "</td><td>" + d["就业单位名称"] + "</td></tr>";
}
string s = "INSERT INTO content(编号,栏目编号,标题,日期,作者,上传日期,内容,审核,审核人,审核日期,隐藏,内容类型,招聘信息编号) VALUES('" +
no + "','0405','撤销录用结果','" +
time + "','招生就业办','" + time + "','" +
head + toAdd + "</table>','01','系统','" +
time + "','显示','内容','y" + id + "')";
objCom.excsql(s);
}
}