Solved

Visual Basic 2005 Updating database with Binding Navigator

Posted on 2006-07-12
6
322 Views
Last Modified: 2013-11-25
I have a simple form in VB2005.  I added a Binding source that connects to an Access Database and a Binding Navigator.  I dragged the data fields onto the form and can view and navigate the data.  I do not know how to change the data ie. Add Delete or Edit.  I understand that I am only changing the dataset.  I need to also update the database with the changes.  Also if possible can the changed be made w/o clicking an update button.  If not it's OK.  Thank you in advance!

0
Comment
Question by:dupont2406
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
6 Comments
 
LVL 5

Accepted Solution

by:
Davidshc76 earned 500 total points
ID: 17105000
You need to create the command add, delete, update when u selec the database............ E.g..

DaGeneral = New OleDbDataAdapter()
DaGeneral.SelectCommand = New OleDbCommand("SELECT * FROM [TABLENAME]", g_objconn)

Dim CB As OleDbCommandBuilder
CB = New OleDbCommandBuilder(DaGeneral)
DaGeneral.InsertCommand = CB.GetInsertCommand()
DaGeneral.UpdateCommand = CB.GetUpdateCommand()
DaGeneral.DeleteCommand = CB.GetDeleteCommand()
DsGeneral = New DataSet()
DaGeneral.Fill(DsGeneral, "GENERAL")
GeneralTable = DsGeneral.Tables("GENERAL")
GenDatasource = New BindingSource(DsGeneral, "GENERAL")
GenDatasource.DataSource = GeneralTable

After change the data in binding fields (TextBox)
DaGeneral.Update --- update the database
DsGeneral.AcceptChanges()

0
 

Author Comment

by:dupont2406
ID: 17105415
What part of the form do I put this code?  ie. form load etc.

and do I need to write the connection string in code or is the binding source and navigator enough?
0
 
LVL 5

Expert Comment

by:Davidshc76
ID: 17105435
You can put this code in Form Load.....

1. build database connection string to the database... e.g. g_objconn
2. put the code suggest ....
3. binding the datasource to textbox
4. create a button for update...

**Note :- your table should have primary key define for commandbuilder ...
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month10 days, 6 hours left to enroll

624 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question