这是我的一个函数,运行了一下,就提示 数据类型不匹配,该如何解决啊
public int Update(Model.Question model)
{
StringBuilder strSql = new StringBuilder();
strSql.Append("UPDATE [Question] SET ");
strSql.Append("Qid="+model.Qid+",");
strSql.Append("Qtitle=@in_Qtitle,");
strSql.Append("Qcon=@in_Qcon,");
strSql.Append("Qreply=@in_Qreply,");
strSql.Append("Qtime=@in_Qtime,");
strSql.Append("Qrtime=@in_Qrtime,");
strSql.Append("Qname=@in_Qname,");
strSql.Append("Qphone=@in_Qphone,");
strSql.Append("lg="+model.lg+",");
strSql.Append("Qview=@in_Qview");
strSql.Append(" WHERE ID=" +model.ID);
DbParameter[] cmdParms = {
ZDHelper.CreateInDbParameter("@in_Qtitle", DbType.String, model.Qtitle),
ZDHelper.CreateInDbParameter("@in_Qcon", DbType.String, model.Qcon),
ZDHelper.CreateInDbParameter("@in_Qreply", DbType.String, model.Qreply),
ZDHelper.CreateInDbParameter("@in_Qtime", DbType.DateTime, model.Qtime),
ZDHelper.CreateInDbParameter("@in_Qrtime", DbType.DateTime, model.Qrtime),
ZDHelper.CreateInDbParameter("@in_Qname", DbType.String, model.Qname),
ZDHelper.CreateInDbParameter("@in_Qphone", DbType.String, model.Qphone),
ZDHelper.CreateInDbParameter("@in_Qview", DbType.Boolean, model.Qview)
};
return ZDHelper.ExecuteNonQuery(CommandType.Text, strSql.ToString(), cmdParms);
}
对应你的参数类型和数据库表字段的类型是否一至。
断点跟踪下,把生成的语句打印出来,就知道那里错了
ZDHelper.CreateInDbParameter("@in_Qtime", DbType.DateTime, #model.Qtime#),
ZDHelper.CreateInDbParameter("@in_Qrtime", DbType.DateTime, #model.Qrtime#),
这样改一下试试呢........Access很变态的.............