Parameters
- entity
- The entity to be added.
// Create a new Order object. Order ord = new Order { OrderID = 12000, ShipCity = "Seattle", OrderDate = DateTime.Now // … }; // Add the new object to the Orders collection. db.Orders.InsertOnSubmit(ord); // Submit the change to the database. try { db.SubmitChanges(); } catch (Exception e) { Console.WriteLine(e); // Make some adjustments. // ... // Try again. db.SubmitChanges(); }
' Create a new Order object. Dim ord As New Order With _ {.OrderID = 12000, _ .ShipCity = "Seattle", _ .OrderDate = DateTime.Now} ' Add the new object to the Orders collection. db.Orders.InsertOnSubmit(ord) ' Submit the change to the database. Try db.SubmitChanges() Catch e As Exception Console.WriteLine(e) ' Make some adjustments. ' ... ' Try again. db.SubmitChanges() End Try
Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2