这段代码总是提示说WHERE 附近有语法错误,请高手帮忙,谢谢!
publicstaticvoidUpdate(Employeeae){SqlDataReaderodr=null;Employeecur=getcur();stringi...
public static void Update(Employee ae)
{
SqlDataReader odr = null;
Employee cur = getcur();
string id = cur.Xuehao;
string sql = "UPDATE Employees SET ";
sql += " Xingming= " + "'" + ae.Xingming + "'" + ",";
sql += " Xuehao= " + "'" + ae.Xuehao + "'" + ",";
sql += " Banjig= " + "'" + ae.Banji + "'" + ",";
sql += " WHERE Xuehao= " + id;
try
{
getconnection();
SqlCommand ocmd = new SqlCommand(sql, con);
ocmd.Connection.Open();
odr = ocmd.ExecuteReader();
}
catch (Exception oe)
{
MessageBox.Show(oe.Message);
}
} 展开
{
SqlDataReader odr = null;
Employee cur = getcur();
string id = cur.Xuehao;
string sql = "UPDATE Employees SET ";
sql += " Xingming= " + "'" + ae.Xingming + "'" + ",";
sql += " Xuehao= " + "'" + ae.Xuehao + "'" + ",";
sql += " Banjig= " + "'" + ae.Banji + "'" + ",";
sql += " WHERE Xuehao= " + id;
try
{
getconnection();
SqlCommand ocmd = new SqlCommand(sql, con);
ocmd.Connection.Open();
odr = ocmd.ExecuteReader();
}
catch (Exception oe)
{
MessageBox.Show(oe.Message);
}
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询