奇怪了...
时间:2011-03-04 来源:双魂人生
public void Update(Maticsoft.Model.Anli model)
{
StringBuilder strSql=new StringBuilder();
strSql.Append("update CN_Anli set ");
strSql.Append("title=@title,");
strSql.Append("photo=@photo,");
strSql.Append("links=@links,");
strSql.Append("content=@content");
strSql.Append(" where id=@id ");
OleDbParameter[] parameters = {
new OleDbParameter("@id", OleDbType.Integer,4),
new OleDbParameter("@title", OleDbType.VarChar,200),
new OleDbParameter("@photo", OleDbType.VarChar,200),
new OleDbParameter("@links", OleDbType.VarChar,200),
new OleDbParameter("@content", OleDbType.VarChar,0)};
parameters[0].Value = model.id;
parameters[1].Value = model.title;
parameters[2].Value = model.photo;
parameters[3].Value = model.links;
parameters[4].Value = model.content;
DbHelperOleDb.ExecuteSql(strSql.ToString(),parameters);
}
这样写竟然不行,原因是id比较放在最后,即:
public void Update(Maticsoft.Model.Anli model)
{
StringBuilder strSql=new StringBuilder();
strSql.Append("update CN_Anli set ");
strSql.Append("title=@title,");
strSql.Append("photo=@photo,");
strSql.Append("links=@links,");
strSql.Append("content=@content");
strSql.Append(" where id=@id ");
OleDbParameter[] parameters = {
new OleDbParameter("@title", OleDbType.VarChar,200),
new OleDbParameter("@photo", OleDbType.VarChar,200),
new OleDbParameter("@links", OleDbType.VarChar,200),
new OleDbParameter("@content", OleDbType.VarChar,0),
new OleDbParameter("@id", OleDbType.Integer,4)};
parameters[0].Value = model.title;
parameters[1].Value = model.photo;
parameters[2].Value = model.links;
parameters[3].Value = model.content;
parameters[4].Value = model.id;
DbHelperOleDb.ExecuteSql(strSql.ToString(),parameters);
}
郁闷...