我面临一个奇怪的问题,当我尝试运行以下代码来更新访问数据库中的记录时。
string updateQuery = "UPDATE Employee SET Employee_name = @name, Employee_desig = @designation, Employee_salary = @salary, Employee_phone = @phone, Employee_mobile = @mobile, Employee_email = @email, Employee_status = @status WHERE (((Employee_id)=@empId));";
dbCmd.CommandText = updateQuery;
dbCmd.Parameters.AddWithValue("@designation", designation);
dbCmd.Parameters.AddWithValue("@email", email);
dbCmd.Parameters.AddWithValue("@mobile", mobile);
dbCmd.Parameters.AddWithValue("@name", name);
dbCmd.Parameters.AddWithValue("@phone", phone);
dbCmd.Parameters.AddWithValue("@salary", salary);
dbCmd.Parameters.AddWithValue("@status", status);
dbCmd.Parameters.AddWithValue("@empId", employeeId);
dbCmd.ExecuteNonQuery();
ExecuteNonQuery()
返回 1。但是当我签入数据库时,输入会在不同的列中更新。
输入值为
designation="Manager"
email="e"
mobile="2"
name="n"
phone="1"
salary=10.0
status="Active"
employeeId=3
任何帮助将不胜感激。