Re: User changing key value
- From: "pvdg42" <pvdg42@xxxxxxxxxxxxxxxxx>
- Date: Tue, 27 Mar 2007 11:08:25 -0500
<easoftware@xxxxxxxxx> wrote in message
news:1174886500.008839.301270@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
I am using VB.Net 2003. I have an Access database with two tables,
Parent and Child. The data is displayed in grids, and when the user
scrolls through the Parent grid, just the related Child data shows in
the Child grid. Simple. Works great.
The user wants to be able to change the value in the primary key of
the Parent table. I set up a form for this, and the forms does all
the error checking to make sure the new key values does not already
exist in the Parent table.
I have a Private var:
Private myBm As BindingManagerBase
My Form.Load event is
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Me.OleDbDataAdapter1.Fill(Me.DataSet11,
Me.DataSet11.Parent.TableName)
Me.OleDbDataAdapter2.Fill(Me.DataSet11,
Me.DataSet11.Child.TableName)
MyBm = BindingContext(Me.DataSet11,
Me.DataSet11.Parent.TableName)
End Sub
After the user has entered a new valid primary key value, I assign it
with:
Dim aRow As DataRow = CType(myBm.Current, DataRowView).Row
aRow("MyKey") = NewKeyValue
All this works fine, but when I assign the new key value, the rows in
the Child grid (linked to the old key value) disappear. If I change
rows in the Parent grid, and then return to the row with the new key
value, then the rows in the Child grid (the ones linked to the old key
value, and now the new key value) reappear. I have confirmed the
values in the linked column in the Child table are updated to the new
key, by having the linked column displayed in the Child grid.
It seams the Child grid does not see the new value of the key field.
I have tried
Dim aRow As DataRow = CType(myBm.Current, DataRowView).Row
aRow("MyKey") = NewKeyValue
myBM.EndCurrentEdit()
but it does not make the fix the problem. How can I make the linked
rows in the Child have their linked key value updated, and remain
being displayed, without having to scroll off and back onto the row in
the Parent grid?
Thanks for any help
Users should not be able to change primary key values!
Allowing them to do so, just begs for data integrity problems. I assume you
are using a natural primary key, thus leading to the request. I would
suggest for the table in question, that you use an artificial primary key (a
sequence, or autonumber in AccessSpeak) and make the field the user wants to
change a non-key field.
.
- References:
- User changing key value
- From: easoftware
- User changing key value
- Prev by Date: Re: How do I add a slider control to my form?
- Next by Date: Disappearing icon in the Toolbox (VS2005)
- Previous by thread: User changing key value
- Next by thread: How do I add a slider control to my form?
- Index(es):
Relevant Pages
|