zoukankan      html  css  js  c++  java
  • ASP.NET MVC 学习笔记 (3)

    学习NerdDinner 时,InsertOnSubmit方法执行后怎么也插入不到数据库中,查找MSDN,找到了原因,原来还要执行一下SubmitChanges方法。

    1 // Create a new Order object.
    2  Order ord = new Order
    3 {
    4 OrderID = 12000,
    5 ShipCity = "Seattle",
    6 OrderDate = DateTime.Now
    7 //
    8  };
    9
    10  // Add the new object to the Orders collection.
    11  db.Orders.InsertOnSubmit(ord);
    12
    13  // Submit the change to the database.
    14  try
    15 {
    16 db.SubmitChanges();
    17 }
    18 catch (Exception e)
    19 {
    20 Console.WriteLine(e);
    21 // Make some adjustments.
    22 // ...
    23 // Try again.
    24 db.SubmitChanges();
    25 }


  • 相关阅读:
    架构师之路
    责任链设计模式
    Junit框架分析
    线程详解
    课程总结
    IO流
    Java第四次作业
    Character string
    实训
    实训SI
  • 原文地址:https://www.cnblogs.com/liming1019/p/1763965.html
Copyright © 2011-2022 走看看