473,383 Members | 1,832 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

Beginner Level: HasChanges always false

Hello,

I am very new to C# and .Net. I may be overlooking something very simple here, however, even after reading several forums I'm still stumped.

I can't get the HasChanges method to work. It always returns false.
I have a dataset on the form (DSCustRow), which is loaded by a different class.
My binding seems to work as the data appears on the form.

When I press the save button, I check for changes on the dataset.
The result is always false. I can move off the field, tab around, update multiple fields and the result is always the same; HasChanges is always false. From other entries, I tried adding AcceptChanges prior to checking with no luck.

I've read other forums on this problem, but the solutions did not work for me.

Thank you very much in advance,
MF


(DSCustRow is defined as a dataset on the form.)

Expand|Select|Wrap|Line Numbers
  1.         private void CustomerDetail_Load(object sender, EventArgs e)
  2.         {
  3.             DBCustomer ldb = new DBCustomer();
  4.             if (this.strInCustSysid.Length > 0)
  5.             {ldb.CustSysid = this.strInCustSysid;}
  6.  
  7.             DataTable dt = ldb.GetCustomerData();
  8.             this.DSCustRow.Tables.Add(dt);
  9.  
  10.             this.CUST_SYSID_PK.DataBindings.Add("Text", this.DSCustRow,
  11. "CUSTOMER.CUST_SYSID_PK");
  12.             this.CUST_NAME.DataBindings.Add("Text", this.DSCustRow,
  13. "CUSTOMER.CUST_NAME");
  14.             this.CUST_ADDR_LINE1.DataBindings.Add("Text", this.DSCustRow,
  15. "CUSTOMER.CUST_ADDR_LINE1");
  16.             this.CUST_ADDR_LINE2.DataBindings.Add("Text", this.DSCustRow,
  17. "CUSTOMER.CUST_ADDR_LINE2");
  18.             this.CUST_CITY.DataBindings.Add("Text", this.DSCustRow,
  19. "CUSTOMER.CUST_CITY");
  20.             this.CUST_STATE.DataBindings.Add("Text", this.DSCustRow,
  21. "CUSTOMER.CUST_STATE");
  22.             this.CUST_POSTAL.DataBindings.Add("Text", this.DSCustRow,
  23. "CUSTOMER.CUST_POSTAL");
  24.         }
  25.  
  26.  
  27.         private void btnSave_Click(object sender, EventArgs e)
  28.         {
  29.             int x;  // for testing
  30.             if (DSCustRow.HasChanges())
  31.             {
  32.                 x = 5;  //never gets here.
  33.             }
  34.  
  35.         }
Mar 31 '07 #1
2 1583
kenobewan
4,871 Expert 4TB
Welcome to the site. Have you tried:
Expand|Select|Wrap|Line Numbers
  1. if (!(DSCustRow.GetChanges() is null))
Mar 31 '07 #2
Welcome to the site. Have you tried:
Expand|Select|Wrap|Line Numbers
  1. if (!(DSCustRow.GetChanges() is null))
Thanks for the info.

I get a syntax error entering: if (!(DSCustRow.GetChanges() is null))

if (!(this.DSCustRow.GetChanges() == null)) is always false.
if (!(this.DSCustRow.GetChanges() is DBNull )) is always true.

This is very strang...I know of an ugly work around, but I'm stubborn when it comes to these things. I need to know what I am doing wrong;)

Thanks again.
Mar 31 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Klatuu | last post by:
I've tried to follow the threads regarding using the HASCHANGES method but still cannot understand how to use it. Situation is this: single dataset, single table, bound to controls on a form....
4
by: thead01 | last post by:
I create a dataset, load xmlfile, create dataview (ds.defaultview) and bind it to a datagrid (dataset haschanges property is now 'true'). When a user closes the form I want to check via...
0
by: Evelin | last post by:
Hi, I use ASP.NET and my problem is I´ve two buttons, a dataSet, a dataGrid and a sqlDataAdpater, I use sqlDataAdapter.fill(dataSet,"dbTable"), then when when the user press the first button, I...
1
by: Osmosis | last post by:
I have a dataset with several different tables and also a combobox with the names of those tables. I'd like the names in the combobox to be bold when the table has any changes. A dataset has...
30
by: dbuchanan | last post by:
ComboBox databindng Problem == How the ComboBox is setup and used: My comboBox is populated by a lookup table. The ValueMember is the lookup table's Id and the DisplayMember is the text from a...
7
by: darjonase | last post by:
I am having a problem, and I wonder if anyone could help me with it. I have two methods. The first on a form calls the second method which is located in a class lib. 'Form Method Private Sub...
4
by: Bails | last post by:
Hi Im an absolute beginner in programming and am using VB.Net Express. To start my larning I decided to do a "Real World" app instead of "hello world" and am creating a Poker Countdown clock. ...
8
by: Miles McGehee | last post by:
I have a DataSet that contains all my data. From this DataSet, let's call it DS, I have 2 views that are based off of 2 seperate tables. We'll call them DataView History and DataView Info. I have a...
15
by: JohnDriver | last post by:
Hello I am learning Ajax and I am following the tutorials found but for some reason, my code is not working. I think I am missing something in the code that I am posting below. Please have a look...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.