|
-
Feb 15th, 2006, 04:21 PM
#1
Thread Starter
New Member
VB Lessons
I am working on the VB 2005 Express Lessons for Beginers that can be found on the MS web site for VB. The current video is #9 on DataBinding. I followed the tutorial and everything works fine except for the updating of the database. It doesn't update. Any thoughts of the top of your collective heads?
-
Feb 15th, 2006, 04:28 PM
#2
Frenzied Member
Re: VB Lessons
Any thoughts of the top of your collective heads?
You did something wrong.
You need to give us a little more detail if you want a better answer unfortunately. Does it give you any error? Does it appear to update but the update is not in the database? Can you give us a little more detail? Also post your code for the update section.
-
Feb 15th, 2006, 04:39 PM
#3
Thread Starter
New Member
Re: VB Lessons
I added a new project, database etc. as instructed by the video. The code was automatically generated by dragging the MyCompanyDataSet over to Form1. The code is shown below. As you know the CustomerBindingNavigator was added. This includes the "Save" option. When I change an element say First Name and then hit Save the database is not updated.
Code Below:
Public Class Form1
Private Sub CustomerBindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Me.Validate()
Me.CustomerBindingSource.EndEdit()
Me.CustomerTableAdapter.Update(Me.MyCompanyDataSet.Customer)
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the 'MyCompanyDataSet.Customer' table. You can move, or remove it, as needed.
Me.CustomerTableAdapter.Fill(Me.MyCompanyDataSet.Customer)
'TODO: This line of code loads data into the 'MyCompanyDataSet.Customer' table. You can move, or remove it, as needed.
Me.CustomerTableAdapter.Fill(Me.MyCompanyDataSet.Customer)
End Sub
Private Sub CustomerBindingNavigatorSaveItem_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CustomerBindingNavigatorSaveItem.Click
Me.Validate()
Me.CustomerBindingSource.EndEdit()
Me.CustomerTableAdapter.Update(Me.MyCompanyDataSet.Customer)
End Sub
End Class
-
Feb 15th, 2006, 04:51 PM
#4
Re: VB Lessons
I don't see anywhere in that code that contains a CommandBuilder, which can autogenerate the insert,update, and delete statements when calling Update. I haven't ever worked with a "TableAdapter", however, but I know this is the case with Data Adapters, so not sure if there is something similar for it.
-
Feb 15th, 2006, 06:53 PM
#5
Re: VB Lessons
Are you sure it is not being updated? Bear in mind that if you rerun the project then you will continue to see the OLD info. The new info should now be updated in the databasefile located in your BIN directory. Each time you rerun your project you are replacing the datafile in the bin directory. Therefore, run your project and change something and save it. Then open your bin directory and run the executable in there and see if your database contains the updated info.
"Imagination is more important than knowledge..."
Albert Einstein
-----------------------------------------------
If my reply helped you then you really were lost, but I still took the time to help, please rate it anyway
-
Feb 15th, 2006, 06:58 PM
#6
Re: VB Lessons
 Originally Posted by gigemboy
I don't see anywhere in that code that contains a CommandBuilder, which can autogenerate the insert,update, and delete statements when calling Update. I haven't ever worked with a "TableAdapter", however, but I know this is the case with Data Adapters, so not sure if there is something similar for it.
Tabl;eAdapters are created along with typed DataSets, so they already have the SQL code needed to save changes. If I'm not mistaken you cannot create a TableAdapter yourself, or at least you aren't supposed to. They should be generated by the IDE froma data source. They are to typed DataSets what DataAdapters are to untyped DataSets.
I also notice that your Load event handler seems to be Filling the same table twice.
-
Feb 16th, 2006, 08:44 AM
#7
Thread Starter
New Member
Re: VB Lessons
Thanks nothingofvalue. The .exe app does indeed update the database. So why do I see the old data when running from within the vb editor? Thanks for you help!
-
Feb 16th, 2006, 09:02 AM
#8
Re: VB Lessons
This question seems to be being asked a lot lately, assuming that it's the same situation.
http://www.vbforums.com/showthread.php?t=386623
-
Feb 16th, 2006, 09:34 AM
#9
Re: VB Lessons
Because it pulls the database file from your project folder but the modified copy is saved in your bin directory. Therefore the original file is left unchanged. You will only see an issue with it while developing. Once the application is finished everything will work as expected.
"Imagination is more important than knowledge..."
Albert Einstein
-----------------------------------------------
If my reply helped you then you really were lost, but I still took the time to help, please rate it anyway
-
Aug 12th, 2007, 06:46 AM
#10
Frenzied Member
Re: VB Lessons
I had the same problem.
I had to build the program and then run it from the exe.
All good
-
Aug 12th, 2007, 08:12 PM
#11
Re: VB Lessons
 Originally Posted by toecutter
I had the same problem.
I had to build the program and then run it from the exe.
All good
You may have done that, but you didn't have to.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|