• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 466
  • Last Modified:

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

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.
0
hesaigo999ca
Asked:
hesaigo999ca
1 Solution
 
hesaigo999caAuthor Commented:
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 differences...how could this be???
0
 
hesaigo999caAuthor Commented:
sorry about that that would be  DataTable dt = DataTable.GetChanges();
0
 
sohilmCommented:
Can you please post the code?
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
MuhammadAdilCommented:
show code
0
 
Bob LearnedCommented:
What does dt.Rows.Count equal?

Bob
0
 
hesaigo999caAuthor Commented:
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 dataset...by 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 differently...here 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;                     
 if(this.BindingContext[dataSet,"invoice"].Position>=0)
 {
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()
{
  if(this.BindingContext[dataSet,"invoice"].Position>=0)
  {                          
  this.BindingContext[dataSet,"invoice"].EndCurrentEdit();
  if(DBComponent.dataSet.Facturation_salle.GetChanges()!=null)
  {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)
   {      
   dataSet.invoice.AcceptChanges();
   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;
 sqlDataAdapterinvoice.Fill(dataSet,"invoice");
 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
         enableAll(true);
       bNotes.Enabled = true;
       this.comRoute.Enabled = false;
         break;
      }
  }
}

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

 try{
sqlDataAdapterinvoice.Update(dataSet,"invoice");
 }
 catch(Exception me)
 {      
  MessageBox.Show(me.message);
  return DialogResult.Cancel;
 }
 Invoice.AcceptChanges();                          
 return DialogResult.Yes;
}
0
 
hesaigo999caAuthor Commented:
>>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. http://msdn2.microsoft.com/en-us/library/system.data.datarowversion.aspx

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
0
 
hesaigo999caAuthor Commented:
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
0
 
Bob LearnedCommented:
Is this true for all columns?

Bob
0
 
hesaigo999caAuthor Commented:
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...http://helpcentral.componentone.com/cs/forums/180225/ShowPost.aspx
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...
0
 
hesaigo999caAuthor Commented:
i did find this article over at msdn...http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=96866&SiteID=1 but they do not go into detail as to the real why  and what should be done about it...
0
 
hesaigo999caAuthor Commented:
I have resolved my question myself based on examples from the sites I have listed above,
http://helpcentral.componentone.com/cs/forums/180225/ShowPost.aspx

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.

0
 
NetminderCommented:
Closed, 300 points refunded.
Netminder
Site Admin
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now