Solved

Visual Basic 2005 Updating database with Binding Navigator

Posted on 2006-07-12
6
314 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
  • 2
6 Comments
 
LVL 5

Accepted Solution

by:
Davidshc76 earned 500 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

763 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

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now