Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Hierarchical Update Problem.

Hierarchical Update Problem.

Scheduled Pinned Locked Moved C#
helpannouncement
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    hdv212
    wrote on last edited by
    #1

    Hi i have 2 tables : Persons (master) Images (detail) each person can multiple images. i'm using tableAdapterManager to accomplish this and here is my code in my DataManager class :

    public bool SavePersonWithImages(MyDataSet DataSet)
    {
    bool saved = false;

           if (DataSet.GetChanges() != null)
           {
               try
               {
                   MyDataSetTableAdapters.PersonsTableAdapter personAdapter = new MyDataSetTableAdapters.PersonsTableAdapter();
                   MyDataSetTableAdapters.ImagesTableAdapter imageAdapter = new MyDataSetTableAdapters.ImagesTableAdapter();
                   MyDataSetTableAdapters.TableAdapterManager manager = new MyDataSetTableAdapters.TableAdapterManager();
    
                   manager.PersonsTableAdapter = personAdapter;
                   manager.ImagesTableAdapter = imageAdapter;
                   int rowAffected = manager.UpdateAll(DataSet);
                   saved = (rowAffected > 0);
                   DataSet.AcceptChanges();
                }
               catch (Exception ex)
               {
                   MessageBox.Show(ex.Message, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                   DataSet.RejectChanges();
               }
    
           }
           return saved;
    

    }

    the insert & delete works fine, but my problem when user edit the image with replace that image with new one, it's works successfully, but when i close the form and open it again, it's don't display image! here is my edit button code :

    private void barBtnEditPerson_ItemClick(object sender, ItemClickEventArgs e)
    {
    if (this.personBindingSource.Count > 0)
    {
    MyDataSet.PersonRow personCurRow = (MyDataSet.PersonRow)((DataRowView)this.personBindingSource.Current).Row;
    FrmZamin frm = new FrmZamin(personCurRow, this.amlakDataSet);
    personCurRow.BeginEdit();
    if (frm.ShowDialog() == DialogResult.OK)
    {
    this._frmLoading = new FrmWait("Saving data ...");
    personCurRow.EndEdit();
    DataManager dm = new DataManager();
    dm.SavePersonWithImages(this.myDataSet);
    this._frmLoading.Close();
    this.backgroundWorker1.RunWorkerAsync();
    }
    else
    {
    personCurRow.CancelEdit();
    }
    this.

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups