public string DoSave(string scode,string sname,DsMaster.TERMSDETAILMASTDataTable Termsdetails) { string retval=string.Empty; SqlTransaction tran = null; var isnew = false; try { var cn = new SqlConnection { ConnectionString = _constr }; cn.Open(); tran = cn.BeginTransaction(IsolationLevel.ReadUncommitted); var dt = new DsMaster().TERMSMAST; var taMast = new DsMasterTableAdapters.TERMSMASTTableAdapter { Connection = { ConnectionString = _constr } }; taMast.Fill(dt); taMast.AssignConnection(cn,tran); var taDetail = new DsMasterTableAdapters.TERMSDETAILMASTTableAdapter() ; taDetail.AssignConnection(cn,tran); var MastRow = dt.FindByTERMCODE(scode); if(MastRow!=null) { MastRow.BeginEdit(); } else { MastRow = (DsMaster.TERMSMASTRow) dt.NewRow(); MastRow.TERMCODE = scode; isnew = true; } MastRow.PAYNAME = sname; if (isnew) { dt.Rows.Add(MastRow); taMast.Update(dt); } else { MastRow.EndEdit(); taMast.Update(dt); } taDetail.Update(Termsdetails); tran.Commit(); retval = "1"; } catch(Exception ex) { if (tran != null) tran.Rollback(); retval = ex.ToString(); } return retval; }