Home All Groups Group Topic Archive Search About

Newbie Missing Something with Access DB Update Using VB .NET

Author
15 Jan 2007 5:49 PM
pooba53
I have a VB .NET application that is communicating properly with an
Access DB. I have a slew of textbox controls bound to a dataset and
when the application launches, the fields are correctly populated.

If someone changes a value in one of the text boxes, I need to have a
button capture the change and commit the update to Access. I know I'm
close, but something is missing. I have a data adapter called:
OleDbDataAdapter1

and a dataset called:
DsMyMonthlyIncome1

My button function is:
Try
OleDbDataAdapter1.Update(DsMyMonthlyIncome1)

Catch ex As Exception
MsgBox(ex.ToString)
End Try

No error occurs, but the changed information in the text field never
gets communicated to the Access DB. Have I not captured the changes by
having the textbox controls bound?

I've searched quite a bit today, and not found the information I seek.
I am lost here and appreciate the help.

I am using VS 2003.

Author
15 Jan 2007 11:50 PM
Bart Mermuys
Hi,

Show quoteHide quote
"pooba53" <poob***@gmail.com> wrote in message
news:1168883383.411233.316440@l53g2000cwa.googlegroups.com...
>I have a VB .NET application that is communicating properly with an
> Access DB. I have a slew of textbox controls bound to a dataset and
> when the application launches, the fields are correctly populated.
>
> If someone changes a value in one of the text boxes, I need to have a
> button capture the change and commit the update to Access. I know I'm
> close, but something is missing. I have a data adapter called:
> OleDbDataAdapter1
>
> and a dataset called:
> DsMyMonthlyIncome1
>
> My button function is:
> Try
> OleDbDataAdapter1.Update(DsMyMonthlyIncome1)

If your update doesn't work only for the last edited field, then you need to
call CurrencyManager.EndCurrentEdit() before the Update.  A CurrencyManager
can be obtained from the Form's BindingContext, eg.:

' Important: use the same DataSource and DataMember(exluding fieldname)
' as the ones you used to setup the bindings.
' If you used the designer to setup the bindings then:
'   DataSource = DsMyMonthlyIncome1
'   DataMember = "YourTableNameHere"
Dim cm As CurrencyManager
cm = DirectCast(BindingContext(DataSource, DataMember),CurrencyManager)
cm.EndCurrentEdit()

OleDbDataAdapter1.Update( DsMyMonthlyIncome1 )

If that doesn't help, then first check whether DataSet has changes before
doing the DataAdapter.Update:
Console.WriteLine( DsMyMonthlyIncome1.HasChanges() )


HTH,
Greetings

Show quoteHide quote
>
> Catch ex As Exception
> MsgBox(ex.ToString)
> End Try
>
> No error occurs, but the changed information in the text field never
> gets communicated to the Access DB. Have I not captured the changes by
> having the textbox controls bound?
>
> I've searched quite a bit today, and not found the information I seek.
> I am lost here and appreciate the help.
>
> I am using VS 2003.
>