「已注销」 2015-02-04 05:25 采纳率: 0%
浏览 918

mybatis.net 向数据库插入数据问题

有一个UserInfo表ID为主键 自增长
在xml文件中

<resultMaps>
<!--UserInfoModel类与db表的映射-->
<resultMap id="SelectAllResult" class="UserInfo">
  <result property="ID" column="ID"/>
  <result property="UserID" column="UserID"/>
  <result property="Name" column="Name" />
  <result property="Password" column="Password"/>
  <result property="Mail" column="Mail" />
  <result property="Phone" column="Phone" />
  <result property="Address" column="Address" />
  <result property="CreateTime" column="CreateTime" />
  <result property="Enable" column="Enable" />
</resultMap>

<!--插入新记录-->
<insert id="InsertUserInfo" parameterClass="UserInfo">
  <!--sql 主键的示例用法-->
  <selectKey resultClass="int" type="post" keyProperty="ID">
    select @@IDENTITY as value
  </selectKey>
  <![CDATA[
  INSERT into UserInfo
  (UserID,
   Name,
   Password,
   Mail,
   Phone,
   Address,
   CreateTime,
   Enable)
   VALUES
   (#UserID#,
   #Name#,
   #Password# ,
   #Mail# ,
   #Phone#,
   #Address#,
   #CreateTime#,
   #Enable#)
   ]]>
</insert>

    前台测试
    public void InsertUserInfo()
    {
        UserInfoModel userInfo=new UserInfoModel();

        userInfo.Address = "南京";
        userInfo.CreateTime = DateTime.Now;
        userInfo.Name = "于硕AAA";
        userInfo.Mail = "12245@qq.com";
        userInfo.UserID = "cast";
        userInfo.Password = "zte@2014";
        userInfo.Phone = "15961820351";
        userInfo.Enable = true;
        _batisDao.Insert("InsertUserInfo", userInfo);

    }

    代码运行的时候总是报这个错误,但是数据库中数据已经插入了 请问下是什么情况
    There is no Set member named '' in class 'UserInfoModel'
  • 写回答

1条回答 默认 最新

  • gglstudy2 2020-10-19 17:32
    关注

    将selectKey子元素的keyProperty”改为“property”,就正常了。

    评论

报告相同问题?

悬赏问题

  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?