/// <summary> /// 更新一条数据 /// </summary> public void Update(ZPY.Model.News model) { StringBuilder strSql=new StringBuilder(); strSql.Append("update News set "); strSql.Append("NewsTitle=@NewsTitle,"); strSql.Append("NewsContent=@NewsContent,"); strSql.Append("NewsFrom=@NewsFrom,"); strSql.Append("NewsTime=@NewsTime,"); strSql.Append("DefaultPic=@DefaultPic,"); strSql.Append("BigClassID=@BigClassID,"); strSql.Append("SmallClassID=@SmallClassID,"); strSql.Append("Hits=@Hits,"); strSql.Append("IsTop=@IsTop,"); strSql.Append("IsPass=@IsPass,"); strSql.Append("AddMan=@AddMan"); strSql.Append(" where ID=@ID "); OleDbParameter[] parameters = { // 注意里面参数的顺利一定要和Update语句里面参数是顺序一致,比如Update语句里面第一个参数 // 是@NewTitle,这里也是,Update语句里面最后一个参数是@ID,这样最后一个参数一定要是@ID new OleDbParameter("@NewsTitle", OleDbType.VarChar,100), new OleDbParameter("@NewsContent", OleDbType.VarChar,0), new OleDbParameter("@NewsFrom", OleDbType.VarChar,50), new OleDbParameter("@NewsTime", OleDbType.Date), new OleDbParameter("@DefaultPic", OleDbType.VarChar,100), new OleDbParameter("@BigClassID", OleDbType.Integer,4), new OleDbParameter("@SmallClassID", OleDbType.Integer,4), new OleDbParameter("@Hits", OleDbType.Integer,4), new OleDbParameter("@IsTop", OleDbType.Boolean,2), new OleDbParameter("@IsPass", OleDbType.Boolean,2), new OleDbParameter("@AddMan", OleDbType.VarChar,50), new OleDbParameter("@ID", OleDbType.Integer,4), }; parameters[0].Value = model.NewsTitle; parameters[1].Value = model.NewsContent; parameters[2].Value = model.NewsFrom; parameters[3].Value = model.NewsTime; parameters[4].Value = model.DefaultPic; parameters[5].Value = model.BigClassID; parameters[6].Value = model.SmallClassID; parameters[7].Value = model.Hits; parameters[8].Value = model.IsTop; parameters[9].Value = model.IsPass; parameters[10].Value = model.AddMan; parameters[11].Value = model.ID; DbHelperOleDb.ExecuteSql(strSql.ToString(),parameters); } //插入一条数据 StringBuilder strSql = new StringBuilder(); strSql.Append("insert into TH_MapMark("); strSql.Append("ExtendName,ExtendDate,BottomLeftX,BottomLeftY,TopRightX,TopRightY,ImgPreview,IsDefaultMark)"); strSql.Append(" values ("); strSql.Append("@ExtendName,@ExtendDate,@BottomLeftX,@BottomLeftY,@TopRightX,@TopRightY,@ImgPreview,@IsDefaultMark)"); OleDbParameter[] parameters = { new OleDbParameter("@ExtendName", OleDbType.VarChar), new OleDbParameter("@ExtendDate", OleDbType.Date), new OleDbParameter("@BottomLeftX", OleDbType.VarChar), new OleDbParameter("@BottomLeftY", OleDbType.VarChar), new OleDbParameter("@TopRightX", OleDbType.VarChar), new OleDbParameter("@TopRightY", OleDbType.VarChar), new OleDbParameter("@ImgPreview", OleDbType.Binary), new OleDbParameter("@IsDefaultMark", OleDbType.Integer)}; parameters[0].Value = name; parameters[1].Value = DateTime.Now; parameters[2].Value = lowerLeftX; parameters[3].Value = lowerLeftY; parameters[4].Value = upperRightX; parameters[5].Value = upperRightY; parameters[6].Value = images; parameters[7].Value = 0; ExecuteSql(strSql.ToString(), parameters);