Newbie Missing Something with Access DB Update Using VB .NET

P

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.
 
B

Bart Mermuys

Hi,

pooba53 said:
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
 
A

aaron.kempf

keep it in Access and use VBA forms

..NET is a failure

the framework isn't on ANYONES desktops.. and it shouldn't be because
it's just bloatware

Access / VBA is fast enough for anything that you need to do; using
..NET all it does is make things SLOWER


-Aaron
 
P

pooba53

Then it requires the user to own a copy of Access, which may not be the
case for who this software is being targeted to.

-Dan
 
P

pooba53

Thanks, Bart!

That's what I needed. I wonder why my book didn't include this useful
bit of information. Probably because the example was using DataGrid,
which may not require a CurrencyManager.

Thanks again.

-Dan
 
A

aaron.kempf

Dan

it doesn't require jack shit and you're not subjected to DLL _HELL_ and
apps that take a half hour to launch

VB.net isn't ready for primetime; I heard that MS is going to kill
VB.net

-Aaron
 
A

aaron.kempf

access is drag and drop; or insert autoform.

..NET is impractical and obsolete

-Aaron
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top