none
Problems with modifying a saved record in C# RRS feed

  • Question

  • HI Team - Here is my issue. I am using C# and SQL. I have windows forms. My users are entering the data in the form and click save. If they close the form and open again to edit the record entered, it works fine.

    The problem is, If I am entering a new record and I click save, I get the message that the record is saved. If I edit the same record without closing the form, it creates a new record. It dosen't modify the old record ( the editting works if I close the form after I save and I open the form and pull that record).

     

    Please help me out.

     

    Thanks

    -TJ

     

    //Code I am using to save

    int currentPosition = BindingContext[accountData, "Account"].Position;

    BindingContext[accountData, "Account"].Position = currentPosition;

    accountTable = (AccountData.AccountDataTable)

    accountData.Account.GetChanges(DataRowState.Added);

    if (accountTable != null)

    {

    accountDALC.Set(accountTable);

    i = 1; // Record was added

    }

    accountTable = (AccountData.AccountDataTable)

    accountData.Account.GetChanges(DataRowState.Modified);

    if (accountTable != null)

    {

    if (MessageBox.Show("Account was edited. Do you wish to save?", "Confirm Save", MessageBoxButtons.YesNo) == DialogResult.Yes)

    {

    accountDALC.Set(accountTable);

    i = 2; // Record was edited

    }

    else

    i = 3; //Discard changes

    }

    accountData.AcceptChanges();

    Monday, June 4, 2007 1:00 PM