public string DoSave(string pname,int bankid=0) { string retval; try { var cn = new SqlConnection { ConnectionString = _constr }; cn.Open(); var dt = new DsMaster().BANKS; bool isnew = false; var ta = new DsMasterTableAdapters.BANKSTableAdapter() { Connection = cn }; ta.Fill(dt); var dr = dt.FindByBANKID(bankid); if (dr != null) { dr.BeginEdit(); } else { dr = (DsMaster.BANKSRow)dt.NewRow(); isnew = true; } dr.BANKNAME = pname; if (isnew) { dt.Rows.Add(dr); ta.Update(dt); } else { dr.EndEdit(); ta.Update(dt); } retval = "1"; } catch (Exception ex) { retval = ex.ToString(); } return retval; }