数据库遍历显示问题!(急!)

duanxinshiyong 2009-04-26 08:50:12
就是我有一张人员简历的工作经历的表,现在要求将表中的内容从数据库中读出并且将值显示在修改界面上。应该如何实现啊!
resume表
resumeId int
rbegin string
rOver string
unit string
office string
coding string 这是跟人员表中有关联的
public List<Resume> GetResumeByCoding(string coding) {
string sql = "select resume.resumeId,resume.rbegin,resume.rOver,resume.unit,resume.office,resume.coding from resume left join rectifierInfos on resume.coding=rectifierInfos.coding where rectifierInfos.coding=@coding";
SqlParameter[] para = new SqlParameter[] {
new SqlParameter("@coding",coding),
};
List<Resume> list = GetResume(sql,para);
if (list.Count > 0) {
return list;
}
return null;
}
这样行不行啊
怎样才能在对应的文本框中显示啊!
...全文
81 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
wwj027 2009-04-26
  • 打赏
  • 举报
回复

GetResumeByCoding(); 返回的是泛型集合
在页面 --- 实体类类型=List.get(i) 在你需要的地方用实体类的取值方法得到值
chen_ya_ping 2009-04-26
  • 打赏
  • 举报
回复
你把从数据库中得到的数据放在了 list这个变量中。
那你可以循环这个变量然得到你要的值 。

蓝海D鱼 2009-04-26
  • 打赏
  • 举报
回复
DataTable mytable = ExecuteDataTable(sql , htParam, CommandType.Text);

CommandType.StoredProcedure是存储过程
蓝海D鱼 2009-04-26
  • 打赏
  • 举报
回复
private DataTable ExecuteDataTable(string SqlStr, Hashtable SqlParameters,CommandType temType)
{

String getConnectionString = "Application Name=sss;Initial Catalog=DEVDB;Data Source=10.3.1.218;User ID=sa;password=sa;Pooling=True";
SqlConnection sqlConn = new SqlConnection(getConnectionString);
SqlCommand sqlCmd = new SqlCommand(SqlStr);
SqlDataAdapter sqlDA =new SqlDataAdapter();
DataTable dtSql = new DataTable();
try
{
sqlConn.Open();
sqlCmd.Connection = sqlConn;
sqlCmd.CommandType = temType;
if (SqlParameters != null)
{
IDictionaryEnumerator hsEnum = SqlParameters.GetEnumerator();
while (hsEnum.MoveNext())
{
sqlCmd.Parameters.AddWithValue(hsEnum.Key.ToString(), hsEnum.Value);
}
}
sqlDA.SelectCommand = sqlCmd;
sqlDA.Fill(dtSql);
return dtSql;
}
catch (Exception exExact)
{
string error = exExact.Message;
throw new Exception(error, exExact);
}
finally
{
sqlConn.Close();
}
}


protected void Button2_Click(object sender, EventArgs e)
{
Hashtable htParam = new Hashtable();

htParam.Add("@coding",coding);
string sql = "select resume.resumeId,resume.rbegin,resume.rOver,resume.unit,resume.office,resume.coding from resume left join rectifierInfos on resume.coding=rectifierInfos.coding where rectifierInfos.coding=@coding";
DataTable mytable = ExecuteDataTable(sql , htParam, CommandType.StoredProcedure);
this.GridView1.DataSource = mytable;
GridView1.DataBind();


}

62,266

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧