Values not getting saved on update?

  • Thread starter Thread starter Woody Splawn
  • Start date Start date
W

Woody Splawn

I have a Winform with a DataSet that involves more than one table. I
thought I had working working well until I discovered today that values in
one of the tables are not getting saved when issuing an update command.

That is, I have a Students table and a Contracts table. I created a data
relation between the two tables (in the yellow schema window) called
DrStudentsContracts.

Lets say I want to bind a textbox to a field called Lname in the contracts
table. I can bind the textbox to a field from the contracts table or I can
bind to the same field in Students.DrStudentsContracts. If I do the later
and I retrieve several students into the Winform and move from record to
record, everything stays in sync. This is as I like it. The problem is
that if I do an update on the contracts table the values don't get saved.

If I bind the textbox to the Lname field in the contracts table (not
Students.DrStudentsContracts) and do an update, things get saved but when
several records are retrieved at the same time and I move from record to
record things don't stay in sync.

Is there a way for me to have my cake and eat it too? How do I set things
up so that I can keep things in sync when moving from record to record but
be able to save too?

At the time that I do the save I call a sub-routine below called
UpdateContracts()

Private Sub UpdateContracts()
Me.BindingContext(DsMain1, "Contracts").EndCurrentEdit()
Try
DaContracts.Update(DsMain1, "Contracts")
Catch ex As System.Data.SqlClient.SqlException
MsgBox(ex.ToString)
Finally
End Try

End Sub
 
Hi Woody,

I think you can bind the Textbox to the Lname field in the contracts table.
So you could update your database properly. If the other fields don't stay
sync, try to refresh them after updating. Refreshing will fill the Textbox
again from the data source.

Does this answer your question? If anything is unclear, please feel free to
reply to the post.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

--------------------
| From: "Woody Splawn" <[email protected]>
| Subject: Values not getting saved on update?
| Date: Wed, 17 Sep 2003 12:24:45 -0700
| Lines: 42
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
| Message-ID: <[email protected]>
| Newsgroups: microsoft.public.dotnet.framework.adonet
| NNTP-Posting-Host: 168.158-60-66-fuji-dsl.static.surewest.net
66.60.158.168
| Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP12.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.adonet:61418
| X-Tomcat-NG: microsoft.public.dotnet.framework.adonet
|
| I have a Winform with a DataSet that involves more than one table. I
| thought I had working working well until I discovered today that values in
| one of the tables are not getting saved when issuing an update command.
|
| That is, I have a Students table and a Contracts table. I created a data
| relation between the two tables (in the yellow schema window) called
| DrStudentsContracts.
|
| Lets say I want to bind a textbox to a field called Lname in the contracts
| table. I can bind the textbox to a field from the contracts table or I
can
| bind to the same field in Students.DrStudentsContracts. If I do the
later
| and I retrieve several students into the Winform and move from record to
| record, everything stays in sync. This is as I like it. The problem is
| that if I do an update on the contracts table the values don't get saved.
|
| If I bind the textbox to the Lname field in the contracts table (not
| Students.DrStudentsContracts) and do an update, things get saved but when
| several records are retrieved at the same time and I move from record to
| record things don't stay in sync.
|
| Is there a way for me to have my cake and eat it too? How do I set things
| up so that I can keep things in sync when moving from record to record but
| be able to save too?
|
| At the time that I do the save I call a sub-routine below called
| UpdateContracts()
|
| Private Sub UpdateContracts()
| Me.BindingContext(DsMain1, "Contracts").EndCurrentEdit()
| Try
| DaContracts.Update(DsMain1, "Contracts")
| Catch ex As System.Data.SqlClient.SqlException
| MsgBox(ex.ToString)
| Finally
| End Try
|
| End Sub
|
|
|
|
|
|
 
Back
Top