dataset used for databindings always returning true for GetChanges() != null even when...

Posted on 2006-05-29
Last Modified: 2010-04-16
I have a form that uses a dataset for a databinding...of its components.
I load info into the form, as all the examples state, then I go and load another from the list
and verify first if dataset.GetChanges!= null in order to save any changed data...always returns
true...for some reason....never did this before...the conversion 2003 to 2005.

Any ideas as to what I might be doing wrong...I can post the code....but if someone knows of any changes done to 2005 datasets that would change the databinding views....I would really appreciate a hand.
Question by:hesaigo999ca

    Author Comment

    ps - I have done the following DataTable dt = dataset.GetChanges();
     then compared all the values from dt to all the values that are in the compoents on the form and there are no could this be???

    Author Comment

    sorry about that that would be  DataTable dt = DataTable.GetChanges();
    LVL 3

    Expert Comment

    Can you please post the code?
    LVL 6

    Expert Comment

    show code
    LVL 96

    Expert Comment

    by:Bob Learned
    What does dt.Rows.Count equal?


    Author Comment

    Form1 is for invoices which is the GUI to the dataset containing table "Invoices"
    Form2 is a search form with a representation of all the invoices in the db with a tdbgrid
    bound on the same doubleclicking the tdbgrid, it should load Form1 with the info for that invoice, the problem is that when I load the info into the databound components of the form, then I choose another , it tells me that the info has changed even though I have gone through great lenghts to compare the DataTable.Current with the DataTable.Orignal info to see there was no change in the data...we recently converted from 2003 to 2005
    and now it seems to see the bindings is the code so far..
    notice that the dataset is set globally so that all forms may see the dataset containing all the tables needed for the app...and also be able to call from one form to another based on current position....or setting based on dataset.invoices.currentposition = x;

    // form2 (searchgrid) doubleclick the grid to load form1 with selected invoice
    private void gridFacts_DoubleClick(object sender, System.EventArgs e)
     CurrencyManager cm = null;                     
    cm = (CurrencyManager) this.BindingContext[DBComponent.dataSet,"Facturation_salle"];
    if(form1.checkState()!=DialogResult.Cancel)                  form1.LoadOne(((DataSet1.Facturation_salleRow)((System.Data.DataRowView)cm.List[this.gridFacts.Row]).Row).ID_facturation_salle);

    //form1 methods
    public DialogResult checkState()
      {answer = MessageBox.Show("Some data has changed in 'invoice' and have not been saved. Do you wish to save before continuing?","Attention",MessageBoxButtons.YesNoCancel,MessageBoxIcon.Question);
      if(answer == DialogResult.Yes)
      { if(save()==DialogResult.Cancel) return DialogResult.Cancel;}
      else if(answer == DialogResult.No)
       return DialogResult.No;
      else if(answer == DialogResult.Cancel) {return DialogResult.Cancel;}
    return DialogResult.Yes;

    private void LoadOne(int id)
     sqlDataAdapterinvoice.SelectCommand.Parameters["@ID_invoice"].Value = id;
     for(int i=DBComponent.dataSet.Facturation_salle.Count-1;i>=0;i--)      
     {      if(DBComponent.dataSet.Facturation_salle[i].ID_facturation_salle == id)
             this.BindingContext[DBComponent.dataSet,"Facturation_salle"].Position = i;            
           //function looping through all form components to enable them to parameter given
           bNotes.Enabled = true;
           this.comRoute.Enabled = false;

    private DialogResult save()
      DataRow updRow = Invoice.Rows[this.BindingContext[dataSet,"Invoice"].Position];
    updRow["date_invoice"]=this.deDate.Value; //dateedit                       
    updRow["invoiced"]=this.cbInvoiceGiven.Checked; //checkbox
    updRow["reimbursment_effected"]=this.cbReimbursment.Checked; //checkbox
    updRow["invoice_amount"]=this.tbAmount.Value; //textbox            

     catch(Exception me)
      return DialogResult.Cancel;
     return DialogResult.Yes;

    Author Comment

    >>What does dt.Rows.Count equal?
    when I getchanges from a load through doubleclick from form2 to form1
    i get 1 which is the total amount of invoices in the global dataset too!
    it is the only one and I used many different ways to see the values
    between the
    DataRowVersion.Current & DataRowVersion.Original of each column in the row...
    based on ref.

    I am without any ideas at this point, other then something has changed in the way the datasets are bound and treated in 2005 compared to 2003, if I knew what they had done diff.
    I could check into it more, but it is poorly documented as to what really changed
    behind the scenes for .NET 2.0

    Author Comment

    here is how i tried to see diff values from original to current if needed....

    DataTable dt = DBComponent.dataSet.Facturation_salle.GetChanges();
    int count = dt.Rows.Count; //returned 1
    DataRow dr = dt.Rows[0];
    if (dr["id_invoice", DataRowVersion.Current] != dr["id_invoice", DataRowVersion.Original])
                            System.Diagnostics.Debug.Print("current - " + dr["id_invoice", DataRowVersion.Current].ToString() + " original - " + dr["id_invoice", DataRowVersion.Original].ToString());
                        if (dr["date_reservation", DataRowVersion.Current] != dr["date_reservation", DataRowVersion.Original])
                            System.Diagnostics.Debug.Print("current - " + dr["date_reservation", DataRowVersion.Current].ToString() + " original - " + dr["date_reservation", DataRowVersion.Original].ToString());
                        if (dr["lieu", DataRowVersion.Current] != dr["lieu", DataRowVersion.Original])
                            System.Diagnostics.Debug.Print("current - " + dr["lieu", DataRowVersion.Current].ToString() + " original - " + dr["lieu", DataRowVersion.Original].ToString());
                        if (dr["id_etablissement", DataRowVersion.Current] != dr["id_etablissement", DataRowVersion.Original])
                            System.Diagnostics.Debug.Print("current - " + dr["id_etablissement", DataRowVersion.Current].ToString() + " original - " + dr["id_etablissement", DataRowVersion.Original].ToString());
                        if (dr["reference_clause", DataRowVersion.Current] != dr["reference_clause", DataRowVersion.Original])
                            System.Diagnostics.Debug.Print("current - " + dr["reference_clause", DataRowVersion.Current].ToString() + " original - " + dr["reference_clause", DataRowVersion.Original].ToString());
                        if (dr["reimbursement", DataRowVersion.Current] != dr["reimbursement", DataRowVersion.Original])
                            System.Diagnostics.Debug.Print("current - " + dr["reimbursement", DataRowVersion.Current].ToString() + " original - " + dr["reimbursement", DataRowVersion.Original].ToString());
                        if (dr["reimbursement_percentage", DataRowVersion.Current] != dr["remboursement_pourcentage", DataRowVersion.Original])
                            System.Diagnostics.Debug.Print("current - " + dr["reimbursement_percentage", DataRowVersion.Current].ToString() + " original - " + dr["reimbursement_percentage", DataRowVersion.Original].ToString());
                        if (dr["reimbursement_amount_max", DataRowVersion.Current] != dr["reimbursement_amount_max", DataRowVersion.Original])
                            System.Diagnostics.Debug.Print("current - " + dr["reimbursement_amount_max", DataRowVersion.Current].ToString() + " original - " + dr["reimbursement_amount_max", DataRowVersion.Original].ToString());
                        if (dr["invoice_given", DataRowVersion.Current] != dr["invoice_given", DataRowVersion.Original])
                            System.Diagnostics.Debug.Print("current - " + dr["invoice_given", DataRowVersion.Current].ToString() + " original - " + dr["invoice_given", DataRowVersion.Original].ToString());
                        if (dr["amount_invoice", DataRowVersion.Current] != dr["amount_invoice", DataRowVersion.Original])
                            System.Diagnostics.Debug.Print("current - " + dr["amount_invoice", DataRowVersion.Current].ToString() + " original - " + dr["amount_invoice", DataRowVersion.Original].ToString());
                        if (dr["reimbursement_effective", DataRowVersion.Current] != dr["reimbursement_effective", DataRowVersion.Original])
                            System.Diagnostics.Debug.Print("current - " + dr["reimbursement_effective", DataRowVersion.Current].ToString() + " original - " + dr["reimbursement_effective", DataRowVersion.Original].ToString());
                        if (dr["amount_reimbursed", DataRowVersion.Current] != dr["amount_reimbursed", DataRowVersion.Original])
                            System.Diagnostics.Debug.Print("current - " + dr["amount_reimbursed", DataRowVersion.Current].ToString() + " original - " + dr["amount_reimbursed", DataRowVersion.Original].ToString());
                        if (dr["goal", DataRowVersion.Current] != dr["goal", DataRowVersion.Original])
                            System.Diagnostics.Debug.Print("current - " + dr["goal", DataRowVersion.Current].ToString() + " original - " + dr["goal", DataRowVersion.Original].ToString());
    and this is the following output only a few columns output

    id_invoice - current - 1 original - 1
    date_reservation - current - 2006-05-15 00:00:00 original - 2006-05-15 00:00:00
    id_etablissement - current - 1 original - 1
    reimbursement - current - True original - True
    reimbursement_percentage - current - 76 original - 76
    reimbursement_amount_max - current - 577,0000 original - 577,0000
    LVL 96

    Expert Comment

    by:Bob Learned
    Is this true for all columns?


    Author Comment

    no actually it is only for a few...but i did read this post over at componentone...(we use some of their components) and their seems to be a work around for the DataRows returning false positives...
    he built a quick function that processes the info and corrects it, although I dont know why microsoft did not do this for 2.0 seeing as it may have been important enough for everyone to save bandwidth using their GetChanges to check for REAL changes....!!!

    I would still like to know if I am missing something from microsoft docs that may help explain this problem...

    Author Comment

    i did find this article over at msdn... but they do not go into detail as to the real why  and what should be done about it...

    Author Comment

    I have resolved my question myself based on examples from the sites I have listed above,

    I am now unaware of how to retract this question, moderators please help as I
    would like to close this question, I am under no obligation to award points if no one properly answered my question to solve it.

    LVL 5

    Accepted Solution

    Closed, 300 points refunded.
    Site Admin

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Find Ransomware Secrets With All-Source Analysis

    Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

    Suggested Solutions

    Title # Comments Views Activity
    ASP.NET C# delay answer writing to file 11 27
    Refresh page ASP.NET C# 3 39
    Path of Workbook 3 30
    report c# 9 56
    Article by: Ivo
    C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
    This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
    how to add IIS SMTP to handle application/Scanner relays into office 365.
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    8 Experts available now in Live!

    Get 1:1 Help Now