private DataTable getDaten() { using (MyContextDataContext myctx = new MyContextDataContext()) { dt.Columns.Add("Lifnr"); dt.Columns.Add("Matchcode"); var query = (from b in myctx.orgLieferanten where b.dbbestand == "PRD" select b); foreach (var dr in query) { row = dt.NewRow(); dt.Rows.Add(dr.lifnr, dr.mcod1); } return(dt); } }
public static string safe(string strlifnr, string strmcod1) { using (MyContextDataContext myctx = new MyContextDataContext(Properties.Settings.Default.MyDBConnectionString)) { var update = (from b in myctx.orgLieferanten where b.dbbestand == "PRD" && (b.lifnr == strlifnr) select b).SingleOrDefault(); update.mcod1 = strmcod1; try { myctx.SubmitChanges(); } catch (Exception ex) { return(ex.Message); } return("1"); } }