windows2003无法安装Windows Live Installer,将就着用CE写了。在对代码的精简下(绿色-->红色代码),由于没有对SqlDbType进行相应的指定类型,出现了object与SqlDbType的异常(系统无法捕获),主要是针对0,找了好久才发现!偷懒反被0耍了,哈哈。当然下面的精简只适合在修改少数字段的情况下方便,对于数目较多的情况下还是采用对象模型方便。
Jasen.Business.Operate operate = new Jasen.Business.Operate();
Jasen.Business.BaseModel baseModel = new Jasen.Business.BaseModel();
Jasen.Business.SysOwnuser ownuser = new Jasen.Business.SysOwnuser();*/
for (int i = 0; i < dgdList.Items.Count; i++)
{
DataGridItem item = dgdList.Items[i];
if (((CheckBox)item.FindControl("chkSelect")).Checked == true)
{
int ID = int.Parse(((CheckBox)item.FindControl("chkSelect")).Text.ToString());
/* baseModel = operate.GetModelby(m_ownuser, "sys_ownuser", "where ownuser_id=" + ID);
ownuser .Equals(baseModel );
ownuser .state = 0;
ownuser.ownuser_id = int.Parse(((CheckBox)item.FindControl("chkSelect")).Text.ToString());
operate.Update(m_ownuser, "sys_ownuser", "ownuser_id");*/
DBTool.ExecuteNonQuery("update sys_ownuser set state =@state where ownuser_id=@ownuser_id", new SqlParameter("@state", 0), new SqlParameter("@ownuser_id", ID));
//Operate Log
Jasen.Business.OperateLog log = new OperateLog();
log.InsertOperationLog("XX", "XX【" + item.Cells[1].Text + "】", OwnUser.Name.ToString(), Request.UserHostAddress.ToString());
}
}
new SqlParameter("@state", 0),对于构造函数public SqlParameter(
foreach (SqlParameter p in commandParameters)
{
if( p != null )
{
// Check for derived output value with no value assigned
if ( ( p.Direction == ParameterDirection.InputOutput || p.Direction == ParameterDirection.Input ) && (p.Value == null))
{
p.Value = DBNull.Value;
}
command.Parameters.Add(p);
}
}
传入@state时系统无法判断0(开始没有设置类型)的类型,默认为null,p.Value 设置成了DBNull.Value;
因此以后有必要针对于0的时候还是不要偷懒,起码设置下0的类型。不要以为sqlparameter构造函数中,0就是个object,传入进去就可以了,嘿嘿。
吃一堑长一智!!!