-
I take on projects of all sizes for businesses of all sizes. Contact me for a no obligation initial discussion.
A properly designed database provides your business with access to up-to-date, accurate information.
Bespoke applications for a independent solution or add-on module will extend the capability of your existing system.
Monthly Archives: October 2012
ADO.NET Insert or Update
This bit of code is great for inserting a record if it does not exist or update the one that does exist in the table.
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
var exists = (from r in db.tAXBusRelStatus where r.BusRelAccount.Equals(_BusRelNo) select r).FirstOrDefault(); // Now check to see if the record exists if (exists == null) { // Do a insert tAXBusRelStatu newRecord = new tAXBusRelStatu() { BusRelAccount = _BusRelNo, BusRelStatus = _Status }; db.AddTotAXBusRelStatus(newRecord); } else { // Do a update exists.BusRelStatus = _Status; } db.SaveChanges(); |
Posted in C# Development
Comments Off on ADO.NET Insert or Update


