動軟—更新的仅仅是其中一个字段,则其他字段都会被更新为空字符。
解决的办法,是将其修改为: 01./// <summary> 02. /// 更新一条数据 03. /// </summary> 04. public void Update(Maticsoft.Model.payment model) 05. { 06. StringBuilder strSql=new StringBuilder(); 07. strSql.Append("update payment set "); 08. strSql.Append("fj_id=ISNULL(@fj_id,fj_id),"); 09. strSql.Append("pay_amount=ISNULL(@pay_amount,pay_amount),"); 10. strSql.Append("pay_date=ISNULL(@pay_date,pay_date),"); 11. strSql.Append("purpose=ISNULL(@purpose,purpose),"); 12. strSql.Append("verify=ISNULL(@verify,verify),"); 13. strSql.Append(" where id=@id "); 14. SqlParameter[] parameters = { 15. new SqlParameter("@id", SqlDbType.Int,4), 16. new SqlParameter("@fj_id", SqlDbType.Int,4), 17. new SqlParameter("@pay_amount", SqlDbType.Money,8), 18. new SqlParameter("@pay_date", SqlDbType.DateTime), 19. new SqlParameter("@purpose", SqlDbType.VarChar,50), 20. new SqlParameter("@verify", SqlDbType.Bit)}; 21. parameters[0].Value = model.id; 22. parameters[1].Value = model.fj_id; 23. parameters[2].Value = model.pay_amount; 24. parameters[3].Value = model.pay_date; 25. parameters[4].Value = model.purpose; 26. parameters[5].Value = model.verify; 27. DbHelperSQL.ExecuteSql(strSql.ToString(),parameters); 28. }