if (DBHelper.addEmployee.Text == "UPDEmployeeForm")
{
string sql = string.Format("select * from Employee inner join Deportment on Employee.EDID=Deportment.DID where EID='{0}'",DBHelper.str);
SqlDataAdapter da = new SqlDataAdapter(sql, DBHelper.con);
DataSet ds = new DataSet();
da.Fill(ds, "UPDEmployee");
foreach (DataRow dr in ds.Tables["Employee"].Rows) //运行到这一步就报错了
{
DBHelper.addEmployee.txtName.Text = dr["EName"].ToString();
DBHelper.addEmployee.txtEID.Text = dr["EID"].ToString();
DBHelper.addEmployee.txtAge.Text = dr["EAge"].ToString();
DBHelper.addEmployee.cboSex.Text = dr["ESex"].ToString();
DBHelper.addEmployee.cboDeportment.Text = dr["DID"].ToString();
}
}
DataSet虚拟表中为空??请高手赐教!!
答案:1 悬赏:30 手机版
解决时间 2021-05-01 15:00
- 提问者网友:佞臣
- 2021-05-01 07:18
最佳答案
- 五星知识达人网友:往事隔山水
- 2021-05-01 08:44
foreach (DataRow dr in ds.Tables["Employee"].Rows)
把这句改成:
foreach (DataRow dr in ds.Tables[0].Rows)
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯