GetChanges in a DataSet

  • Thread starter Thread starter developer
  • Start date Start date
D

developer

Normally I can verify if a datasets content has changed on
an event like a button click. In my case I would like to
do this check on the form closing event. When I make the
checkup I get the original dataset with without the
changes that are supposed to have taken place. Even when
I "watch" the dataset with the debugger I notice that
there are no changes that took place. I am trying to
figure out why.

I would like to know what is the proper way to check if a
dataset has been modified on the closing event.

I tried: if(DataSet.HasChange())

It didn't work!!!

Thanks for the help
 
Normally I can verify if a datasets content has changed on
an event like a button click. In my case I would like to
do this check on the form closing event. When I make the
checkup I get the original dataset with without the
changes that are supposed to have taken place. Even when
I "watch" the dataset with the debugger I notice that
there are no changes that took place. I am trying to
figure out why.

I would like to know what is the proper way to check if a
dataset has been modified on the closing event.

I tried: if(DataSet.HasChange())

Are you running EndEdit on the current DataRow before checking for changes?

Regards,
Kevin McNeish
..NET /C# MVP
Chief Software Architect, Mere Mortals .NET Framework
www.oakleafsd.com
 
ListTransport.q_TransportList
[this.dataGrid1.CurrentRowIndex].EndEdit();

if(ListTransport.HasChanges())
{
string ss= "fsjd";
}

I tried this and it still dont work. It never enter in the
if.
 
If it could help someone to help me, the HasChange work
only when a line is inserted not when it's a update.
-----Original Message-----
ListTransport.q_TransportList
[this.dataGrid1.CurrentRowIndex].EndEdit();

if(ListTransport.HasChanges())
{
string ss= "fsjd";
}

I tried this and it still dont work. It never enter in the
if.

-----Original Message-----
changed
if
a

Are you running EndEdit on the current DataRow before checking for changes?

Regards,
Kevin McNeish
..NET /C# MVP
Chief Software Architect, Mere Mortals .NET Framework
www.oakleafsd.com


.
.
 
Hello,

You need to end edit of both DataGrid and BindingContext in the Closing
event handler. Here is a sample code:

private void Form1_Closing(object sender,
System.ComponentModel.CancelEventArgs e)
{
//Call EndEdit() on the datagrid
dataGrid1.EndEdit(null, dataGrid1.CurrentRowIndex, false);
//Call EndCurrentEdit() on the binding context
dataGrid1.BindingContext[dataGrid1.DataSource,
dataGrid1.DataMember].EndCurrentEdit();
Console.WriteLine(dataSet1.HasChanges().ToString());
}

I hope this helps you.

Best regards,

Lion Shi [MSFT]
MCSE, MCSD
Microsoft Support Engineer
Get Secure! ¨C www.microsoft.com/security

This posting is provided "AS IS" with no warranties, and confers no rights.
You assume all risk for your use. 2003 Microsoft Corporation. All rights
reserved.
--------------------
| Content-Class: urn:content-classes:message
| From: "developer" <[email protected]>
| Sender: "developer" <[email protected]>
| References: <[email protected]>
<[email protected]>
| Subject: Re: GetChanges in a DataSet
| Date: Wed, 27 Aug 2003 07:30:16 -0700
| Lines: 40
| Message-ID: <[email protected]>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="iso-8859-1"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
| Thread-Index: AcNsp7vpf90iDsM/SRu6tYCOHcTevg==
| Newsgroups: microsoft.public.dotnet.framework.windowsforms
| Path: cpmsftngxa06.phx.gbl
| Xref: cpmsftngxa06.phx.gbl
microsoft.public.dotnet.framework.windowsforms:51006
| NNTP-Posting-Host: TK2MSFTNGXA09 10.40.1.161
| X-Tomcat-NG: microsoft.public.dotnet.framework.windowsforms
|
| ListTransport.q_TransportList
| [this.dataGrid1.CurrentRowIndex].EndEdit();
|
| if(ListTransport.HasChanges())
| {
| string ss= "fsjd";
| }
|
| I tried this and it still dont work. It never enter in the
| if.
|
| >-----Original Message-----
| >> Normally I can verify if a datasets content has changed
| on
| >> an event like a button click. In my case I would like to
| >> do this check on the form closing event. When I make the
| >> checkup I get the original dataset with without the
| >> changes that are supposed to have taken place. Even when
| >> I "watch" the dataset with the debugger I notice that
| >> there are no changes that took place. I am trying to
| >> figure out why.
| >>
| >> I would like to know what is the proper way to check if
| a
| >> dataset has been modified on the closing event.
| >>
| >> I tried: if(DataSet.HasChange())
| >
| >Are you running EndEdit on the current DataRow before
| checking for changes?
| >
| >Regards,
| >Kevin McNeish
| >..NET /C# MVP
| >Chief Software Architect, Mere Mortals .NET Framework
| >www.oakleafsd.com
| >
| >
| >.
| >
|
 
Back
Top