Hiya,
I have a windows form displaying a dataset from a select query and I am trying to find a way to determine when my datset has changed so I can pop a message box when the naviagte to a different record or close the form asking the user if he/she would like to save. I came across the HasChanges() method which seemed like a grand idea but when I try it like:
if (myDataset.HasChanges())
{
pop me a MessageBox() to save or discard;
}
else
{
....just keep on rolling;
}
......my app will not build explaining that I am missing an object reference and as expected, when I press the . to the right of the dataset there is no haschanges method available. The system.data reference is there, hence I am baffled. I am using C# with Visual Studio 2005 with a pretty generic set of TableAdapters and generic SQL Select statements. Can someone help me here
J.H.

Where o' where has my "HasChanges() gone"?
Meta
Ya, no kidding! I did notice a difference in the case of the type. MyDataSet and mydataset are indeed two completely different objects.
Thanks for noticing.
J.H.
Sergey Karimov
A-Hah! I was correct in my assumption that .net is indeed creating the datasets for me and instantiating them. My oversite was a simple lack of adding "this" to my call. Should be....
if (this.mydataset.HasChanges())
Works like a charm...Thanks anyhoo.
J.H.
abzz
Just a stab in the dark...is it boolean
if (myDataset.HasChanges() = True)
---edited---oops sorry...you already figured it out...lol
Adamus
dajeeper
Well, maybe I am confused about something here. Doesn't C# create this dataset for me when the application runs the select statement I can see my data in the form, I can navigate it and change it without doing any saves, deletes, or updates back to the database. Isn't this existing dataset accessible without instantiating and filling another one I am presuming, perhaps wrong, that this class is already being created and filled for me...Can someone clarify
J.H.
Javalier
NoviceGeek
Hi,
Just a note that this doesn't solve anything in this case. Your problem was casing of mydataset - mydataset is an instance while myDataset is a type in your case I assume.
Thus even dropping this should work if you write mydataset.