472,975 Members | 1,477 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Datagrid and dataset 'haschanges' problem

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 ds.haschanges if there
are pending changes in the dataset. Now returns 'true' always.
When I say 'acceptchanges' after loading the xmlfile, the haschanges
always says 'false' when closing the form.
Guess I'm missing something. Alternative solution to check for pending
changes when closing the form is also fine.

Jul 21 '05 #1
4 4993
Thread,

No you are missing nothing, acceptchanges mean set all datarows to the
rowstate unchanged.

I hope this helps,

Cor
Jul 21 '05 #2
Okay, let's try to make my problem clear. Here are the form load en
close events. Reason I use a dataview is that I won't allow the user to
add a new record.
My problem is that using 'haschanges' is not reliable for the purpose I
use it for.

Private Sub frmEditOptions_Load(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles MyBase.Load
ds1.ReadXml(gstrFile)
Dim dv As New DataView
dv = ds1.Tables("Options").DefaultView()
dv.AllowNew = False
With DataGrid1
.DataSource = dv
.CaptionText = "Options"
End With
End Sub

Private Sub frmEditOptions_Closing(ByVal sender As Object, ByVal e
As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
Dim s As String
If ds1.HasChanges() Then
If MsgBox("Wijzigingen opslaan?", MsgBoxStyle.YesNo +
MsgBoxStyle.Question) = MsgBoxResult.Yes Then
WriteXmlToFile(ds1, gstrFile)
End If
End If
End Sub

Jul 21 '05 #3
Okay, let's try to make my problem clear. Here are the form load en
close events. Reason I use a dataview is that I won't allow the user to

add a new record. My problem is that using 'haschanges' is not reliable
for the purpose I use it for.

dim ds1 as new dataset
Private Sub frmEditOptions_Load(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles MyBase.Load
ds1.ReadXml(gstrFile)
Dim dv As New DataView
dv = ds1.Tables("Options").DefaultV*iew()
dv.AllowNew = False
With DataGrid1
.DataSource = dv
.CaptionText = "Options"
End With
End Sub
Private Sub frmEditOptions_Closing(ByVal sender As Object, ByVal e
As System.ComponentModel.CancelEv*entArgs) Handles MyBase.Closing
Dim s As String
If ds1.HasChanges() Then
If MsgBox("Wijzigingen opslaan?", MsgBoxStyle.YesNo +
MsgBoxStyle.Question) = MsgBoxResult.Yes Then
WriteXmlToFile(ds1, gstrFile)
End If
End If
End Sub


Cor Ligthert schreef:
Thread,

No you are missing nothing, acceptchanges mean set all datarows to the
rowstate unchanged.

I hope this helps,

Cor


Jul 21 '05 #4
Ad,

I don't see what there is wrong and I see only a small part of your code,
however probably the last changed row will not be updated, therefore I would
add something as
Private Sub frmEditOptions_Closing(ByVal sender As Object, ByVal e
As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
Dim s As String
BindingContext(ds1.Tables("Options").EndCurrentEdi t()
If ds1.HasChanges() Then
If MsgBox("Wijzigingen opslaan?", MsgBoxStyle.YesNo +
MsgBoxStyle.Question) = MsgBoxResult.Yes Then
WriteXmlToFile(ds1, gstrFile)
End If
End If
End Sub


I hope this helps

Cor
Jul 21 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Michael Dimento | last post by:
I'm trying to detect if there are any unsaved changes in a dataset when a user hits close form button (top right hand corner). My problem is that HasChanges does not detect a row that has been...
6
by: BFX | last post by:
Hi All, I have datagrid with binding on dataset this.grdMachineType.DataMember = "MachineTypes"; this.grdMachineType.DataSource = this.dsMachineTypes; After append new row in datagrid i...
0
by: TK | last post by:
Hi, I need help on datagrid. I have a dataset exposed as a webservice. I do have a web application that is supposed to consume the service on a datagrid.
3
by: matthew schouppe | last post by:
I have a datagrid with two columns, the first a normal bound column, the second is a template column created from a bound column. For the ItemTemplate of the Template Column, I removed the label...
0
by: Geraldine Hobley | last post by:
Hello, I have a problem whereby I have datagrid bound to a dataset with the following properties I have put a similar problem up b4 but I still do not have an answer. MyDatagrid.DataSource =...
6
by: Jan Nielsen | last post by:
Hi I asked this question some weeks ago, but have found no soluion yet, so I try again I have a parent detail relationship between two tables. The detail records are shown in a datagrid...
3
by: Jim | last post by:
I have a datagrid with a DataAdapter as the DataSource. The user fills in their data for 3 columns and I want to programically add a value to the 4th (invisible) column (employee number). That way...
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...
3
by: John Sheppard | last post by:
Hello there, I have the following code; I do this as a work around for a dataset.haschanges method which doesnt appear to work correctly either For Each dt As DataTable In myDs.Tables If Not...
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
4
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

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.