不知道什么原因了
public static void updatebtn()
{ //myEmployee是类
Employee myEmployee = currentEmployee();
int id = myEmployee.Number;
conn.Open();
SqlCommand cmd = new SqlCommand("update Class set myclass='"+myEmployee.Myclass +"',mager='"+myEmployee .Mager +"',name='"+myEmployee .Name +"',sex='"+myEmployee .Sex +"',address='"+myEmployee .Address +"',tel="+myEmployee.Tel +",prefer='"+myEmployee .Prefer +"',city='"+myEmployee .City +"',postnumber="+myEmployee .Postnumber +" where number="+id+"",conn );
int i= cmd.ExecuteNonQuery();
conn.Close();
}
public static void deletebtn()
{
Employee myEmployee = currentEmployee();
int id = myEmployee.Number;
conn.Open();
SqlCommand cmd = new SqlCommand("delete from Class where number="+id +"",conn );
int j = cmd.ExecuteNonQuery();
conn.Close();
}
测试结果发现id的值总为0,也没有发现程序中哪里错了,姑且不说。
i,j的值都为零,可是让我不解的是删除操作竟然能进行,而且都删了指定的行,数据库里也删了,按理说
j的值为0,删除应该是失败的啊?请求解释一下