473,387 Members | 1,304 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,387 software developers and data experts.

HasChanges not being updated?

Hi all,

I'm sure I must be missing something here.. I've created a simple parent -
child form appl. in which I open a dataset in the parent (MDI) using a
dataadaptor to an Access database, and a dataset.

The SELECT of the record set searches for a specific entry, if it returns a
0 rowcount, I go throiugh the motions of adding a row, and opening the child
form.. if it is found I just open the child form..

I am passing the dataset through the constuctor to my child form, and if I
use a datagrid to change the data, it marks the HasChanges correctly.
But, as i am only dealing with one row here, and I would like to use text
boxes for each column, I have tried to bind these in code - taken from the
..NET library...DataBindings entry...

The problem is, if I change the data in a text box, (incidentally, if I
leave the datagrid on the form, the cell appears to update for the changed
text), the HasChanges flag is not being set to True. Is there something I
need to code that will cause this to happen?

Here's a snippet of the code...

Parent form:

With daLinkMAN_client_trans

.SelectCommand.Parameters("nman_path").Value = str_nman_path

.Fill(dsLinkMAN)

End With

' if empty then add

If dsLinkMAN.Tables("client_trans").Rows.Count = 0 Then

Dim dr_client_trans As DataRow

dr_client_trans = dsLinkMAN.Tables("client_trans").NewRow

With dr_client_trans

.Item("nman_path") = str_nman_path

.Item("description") = "New database"

.Item("summit_client_id") = ""

dsLinkMAN.Tables("client_trans").Rows.Add(dr_clien t_trans)

End With

End If

' open client form

Dim frm As New frmClient(daLinkMAN_client_trans, dsLinkMAN, cnLinkMAN)

' frm.MdiParent = Me

frm.ShowDialog()

Debug.WriteLine(dsLinkMAN.HasChanges)

Debug.WriteLine(dsLinkMAN.HasErrors)

daLinkMAN_client_trans.Update(dsLinkMAN.Tables("cl ient_trans"))

dsLinkMAN.Tables("client_trans").Clear()

In the Child form I have...

txtpath.DataBindings.Add(New Binding("Text", ds_client_trans,
"client_trans.nman_path"))

txtdescription.DataBindings.Add(New Binding("Text", ds_client_trans,
"client_trans.description"))

txtclient.DataBindings.Add(New Binding("Text", ds_client_trans,
"client_trans.summit_client_id"))

DataGrid1.DataSource = ds_client_trans.Tables("client_trans")
If anyone could shed any light on this I'd be most grateful.

Thanks,
Graham

Jul 21 '05 #1
3 1535
It looks like it thinks no changes have occurred b/c it's still editing.
call .EndCurrentEdit before you call Update and that should do it for you. I
don't see the code for the BindingContext/BindingManagerBase but I'm
guessing it's in there .. if not, you'll probably wwant to add it so you can
navigate and all. If you are unfamiliar with it, google for
BindingManagerbase and/or BindingContext.

HTH,

Bill

--
W.G. Ryan MVP Windows - Embedded

http://forums.devbuzz.com
http://www.knowdotnet.com/dataaccess.html
http://www.msmvps.com/williamryan/
"Graham Blandford" <gr**************@sympatico.ca> wrote in message
news:ux*********************@news20.bellglobal.com ...
Hi all,

I'm sure I must be missing something here.. I've created a simple parent - child form appl. in which I open a dataset in the parent (MDI) using a
dataadaptor to an Access database, and a dataset.

The SELECT of the record set searches for a specific entry, if it returns a 0 rowcount, I go throiugh the motions of adding a row, and opening the child form.. if it is found I just open the child form..

I am passing the dataset through the constuctor to my child form, and if I
use a datagrid to change the data, it marks the HasChanges correctly.
But, as i am only dealing with one row here, and I would like to use text
boxes for each column, I have tried to bind these in code - taken from the
.NET library...DataBindings entry...

The problem is, if I change the data in a text box, (incidentally, if I
leave the datagrid on the form, the cell appears to update for the changed
text), the HasChanges flag is not being set to True. Is there something I
need to code that will cause this to happen?

Here's a snippet of the code...

Parent form:

With daLinkMAN_client_trans

.SelectCommand.Parameters("nman_path").Value = str_nman_path

.Fill(dsLinkMAN)

End With

' if empty then add

If dsLinkMAN.Tables("client_trans").Rows.Count = 0 Then

Dim dr_client_trans As DataRow

dr_client_trans = dsLinkMAN.Tables("client_trans").NewRow

With dr_client_trans

.Item("nman_path") = str_nman_path

.Item("description") = "New database"

.Item("summit_client_id") = ""

dsLinkMAN.Tables("client_trans").Rows.Add(dr_clien t_trans)

End With

End If

' open client form

Dim frm As New frmClient(daLinkMAN_client_trans, dsLinkMAN, cnLinkMAN)

' frm.MdiParent = Me

frm.ShowDialog()

Debug.WriteLine(dsLinkMAN.HasChanges)

Debug.WriteLine(dsLinkMAN.HasErrors)

daLinkMAN_client_trans.Update(dsLinkMAN.Tables("cl ient_trans"))

dsLinkMAN.Tables("client_trans").Clear()

In the Child form I have...

txtpath.DataBindings.Add(New Binding("Text", ds_client_trans,
"client_trans.nman_path"))

txtdescription.DataBindings.Add(New Binding("Text", ds_client_trans,
"client_trans.description"))

txtclient.DataBindings.Add(New Binding("Text", ds_client_trans,
"client_trans.summit_client_id"))

DataGrid1.DataSource = ds_client_trans.Tables("client_trans")
If anyone could shed any light on this I'd be most grateful.

Thanks,
Graham

Jul 21 '05 #2
Thanks Bill,

I finally have it working - and yes - had to use the BMB ... wasn;t readily
apparent I had to do this.... most of the doc. examples used the datagrid so
no mention of it...

Graham

"William Ryan eMVP" <do********@comcast.nospam.net> wrote in message
news:OS**************@tk2msftngp13.phx.gbl...
It looks like it thinks no changes have occurred b/c it's still editing.
call .EndCurrentEdit before you call Update and that should do it for you. I don't see the code for the BindingContext/BindingManagerBase but I'm
guessing it's in there .. if not, you'll probably wwant to add it so you can navigate and all. If you are unfamiliar with it, google for
BindingManagerbase and/or BindingContext.

HTH,

Bill

--
W.G. Ryan MVP Windows - Embedded

http://forums.devbuzz.com
http://www.knowdotnet.com/dataaccess.html
http://www.msmvps.com/williamryan/
"Graham Blandford" <gr**************@sympatico.ca> wrote in message
news:ux*********************@news20.bellglobal.com ...
Hi all,

I'm sure I must be missing something here.. I've created a simple parent -
child form appl. in which I open a dataset in the parent (MDI) using a
dataadaptor to an Access database, and a dataset.

The SELECT of the record set searches for a specific entry, if it returns a
0 rowcount, I go throiugh the motions of adding a row, and opening the

child
form.. if it is found I just open the child form..

I am passing the dataset through the constuctor to my child form, and if

I use a datagrid to change the data, it marks the HasChanges correctly.
But, as i am only dealing with one row here, and I would like to use text boxes for each column, I have tried to bind these in code - taken from the .NET library...DataBindings entry...

The problem is, if I change the data in a text box, (incidentally, if I
leave the datagrid on the form, the cell appears to update for the changed text), the HasChanges flag is not being set to True. Is there something I need to code that will cause this to happen?

Here's a snippet of the code...

Parent form:

With daLinkMAN_client_trans

.SelectCommand.Parameters("nman_path").Value = str_nman_path

.Fill(dsLinkMAN)

End With

' if empty then add

If dsLinkMAN.Tables("client_trans").Rows.Count = 0 Then

Dim dr_client_trans As DataRow

dr_client_trans = dsLinkMAN.Tables("client_trans").NewRow

With dr_client_trans

.Item("nman_path") = str_nman_path

.Item("description") = "New database"

.Item("summit_client_id") = ""

dsLinkMAN.Tables("client_trans").Rows.Add(dr_clien t_trans)

End With

End If

' open client form

Dim frm As New frmClient(daLinkMAN_client_trans, dsLinkMAN, cnLinkMAN)

' frm.MdiParent = Me

frm.ShowDialog()

Debug.WriteLine(dsLinkMAN.HasChanges)

Debug.WriteLine(dsLinkMAN.HasErrors)

daLinkMAN_client_trans.Update(dsLinkMAN.Tables("cl ient_trans"))

dsLinkMAN.Tables("client_trans").Clear()

In the Child form I have...

txtpath.DataBindings.Add(New Binding("Text", ds_client_trans,
"client_trans.nman_path"))

txtdescription.DataBindings.Add(New Binding("Text", ds_client_trans,
"client_trans.description"))

txtclient.DataBindings.Add(New Binding("Text", ds_client_trans,
"client_trans.summit_client_id"))

DataGrid1.DataSource = ds_client_trans.Tables("client_trans")
If anyone could shed any light on this I'd be most grateful.

Thanks,
Graham


Jul 21 '05 #3
Yep, that'll get you and it's an easy thing to overlook, I know I sure did.
Glad you got it working though.

Cheers,

Bill

--

W.G. Ryan, eMVP

http://forums.devbuzz.com/
http://www.knowdotnet.com/williamryan.html
http://www.msmvps.com/WilliamRyan/
http://www.devbuzz.com/content/zinc_...center_pg1.asp
"Graham Blandford" <gr**************@sympatico.ca> wrote in message
news:sH*********************@news20.bellglobal.com ...
Thanks Bill,

I finally have it working - and yes - had to use the BMB ... wasn;t readily apparent I had to do this.... most of the doc. examples used the datagrid so no mention of it...

Graham

"William Ryan eMVP" <do********@comcast.nospam.net> wrote in message
news:OS**************@tk2msftngp13.phx.gbl...
It looks like it thinks no changes have occurred b/c it's still editing.
call .EndCurrentEdit before you call Update and that should do it for you.
I
don't see the code for the BindingContext/BindingManagerBase but I'm
guessing it's in there .. if not, you'll probably wwant to add it so you can
navigate and all. If you are unfamiliar with it, google for
BindingManagerbase and/or BindingContext.

HTH,

Bill

--
W.G. Ryan MVP Windows - Embedded

http://forums.devbuzz.com
http://www.knowdotnet.com/dataaccess.html
http://www.msmvps.com/williamryan/
"Graham Blandford" <gr**************@sympatico.ca> wrote in message
news:ux*********************@news20.bellglobal.com ...
Hi all,

I'm sure I must be missing something here.. I've created a simple

parent -
child form appl. in which I open a dataset in the parent (MDI) using a
dataadaptor to an Access database, and a dataset.

The SELECT of the record set searches for a specific entry, if it

returns
a
0 rowcount, I go throiugh the motions of adding a row, and opening the

child
form.. if it is found I just open the child form..

I am passing the dataset through the constuctor to my child form, and if I use a datagrid to change the data, it marks the HasChanges correctly.
But, as i am only dealing with one row here, and I would like to use text boxes for each column, I have tried to bind these in code - taken from the .NET library...DataBindings entry...

The problem is, if I change the data in a text box, (incidentally, if
I leave the datagrid on the form, the cell appears to update for the
changed text), the HasChanges flag is not being set to True. Is there
something I need to code that will cause this to happen?

Here's a snippet of the code...

Parent form:

With daLinkMAN_client_trans

.SelectCommand.Parameters("nman_path").Value = str_nman_path

.Fill(dsLinkMAN)

End With

' if empty then add

If dsLinkMAN.Tables("client_trans").Rows.Count = 0 Then

Dim dr_client_trans As DataRow

dr_client_trans = dsLinkMAN.Tables("client_trans").NewRow

With dr_client_trans

.Item("nman_path") = str_nman_path

.Item("description") = "New database"

.Item("summit_client_id") = ""

dsLinkMAN.Tables("client_trans").Rows.Add(dr_clien t_trans)

End With

End If

' open client form

Dim frm As New frmClient(daLinkMAN_client_trans, dsLinkMAN, cnLinkMAN)

' frm.MdiParent = Me

frm.ShowDialog()

Debug.WriteLine(dsLinkMAN.HasChanges)

Debug.WriteLine(dsLinkMAN.HasErrors)

daLinkMAN_client_trans.Update(dsLinkMAN.Tables("cl ient_trans"))

dsLinkMAN.Tables("client_trans").Clear()

In the Child form I have...

txtpath.DataBindings.Add(New Binding("Text", ds_client_trans,
"client_trans.nman_path"))

txtdescription.DataBindings.Add(New Binding("Text", ds_client_trans,
"client_trans.description"))

txtclient.DataBindings.Add(New Binding("Text", ds_client_trans,
"client_trans.summit_client_id"))

DataGrid1.DataSource = ds_client_trans.Tables("client_trans")
If anyone could shed any light on this I'd be most grateful.

Thanks,
Graham



Jul 21 '05 #4

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

Similar topics

2
by: jbsound | last post by:
I have been banging my head against this one and I'm sure I'm missing something: Got a WinForms app in VB.NET with controls bound to a dataset. For the sake of this discussion, let's use just...
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: Graham Blandford | last post by:
Hi all, I'm sure I must be missing something here.. I've created a simple parent - child form appl. in which I open a dataset in the parent (MDI) using a dataadaptor to an Access database, and...
2
by: mrstrong | last post by:
Gday, Have been going through the walkthrough for a distributed application: http://msdn2.microsoft.com/en-us/library/1as0t7ff.aspx and it appears to suggest in the SaveData_Click method that...
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...
2
by: mikeficklonni | last post by:
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. ...
4
by: John | last post by:
Hello, I was wondering if it was possibly to bind a control to a dataset.haschanges property. The reason I want to do this is so that a little warning shows up on the form saying that the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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
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...
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.