Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Visual Basic 2005 Updating database with Binding Navigator

Posted on 2006-07-12
6
Medium Priority
?
323 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 2000 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
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…
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…
Suggested Courses

715 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