Xtreme Visual Basic Talk

Xtreme Visual Basic Talk (http://www.xtremevbtalk.com/)
-   .NET Database and Reporting (http://www.xtremevbtalk.com/-net-database-and-reporting/)
-   -   Update Doesn't Update (http://www.xtremevbtalk.com/-net-database-and-reporting/327335-update-doesnt-update.html)

sirmilt 10-13-2014 11:08 AM

Update Doesn't Update
I am using Visual Basic 2010 with an SQL Server2005 Express database. My database table is relatively simple with only six columns but I can't get the database to save.

My form has a DataGridView and 6 Text Boxes all created by dragging data from the data source. everything seems to work fine until I try to Update, using the following code:

Private Sub TblPasswordDetailsBindingNavigatorSaveItem_Click(sender As System.Object, e As System.EventArgs) Handles TblPasswordDetailsBindingNavigatorSaveItem.Click
Me.TblPasswordDetailsTableAdapter.Update(Me.CareTakerDataSet.tblPasswo rdDetails)
MsgBox("Update successful")

Catch ex As Exception
End Try
End Sub

This throws the error: "System.Invalid Operation Exception: Update requires a valid Update Command when passed DataRow collection with modified rows. As you can see my code is taken directly from the MSDN web site. To provide the other details, The Table Adapter, DataSet, table name are correctly entered.

I have tried using this code with my entries directly to the DataGridView and also with the data entry to the associated Text Box controls to no avail, I have gone over the various properties and find nothing.

I am lost, I thought I was following the suggested procedure and can't figure out where the problem comes from. The only difference I see is that I am using SQL Server and Access is used in the example.


JustinCase2 02-24-2015 07:26 AM

Define a statement
To update a table adapter (or Select, delete etc), it needs to know what SQL statements to run for each of those. I believe there is a property on the tableadapter for this. However, if you generated this adapter through a wizard or something, only the Select statement is default generated, and there would have been options for "Auto generate update/delete statements" or similar in the wizard. You will need to check those. :)

All times are GMT -6. The time now is 05:19 PM.

Powered by vBulletin® Version 3.8.9
Copyright ©2000 - 2018, vBulletin Solutions, Inc.
Search Engine Optimisation provided by DragonByte SEO v2.0.15 (Lite) - vBulletin Mods & Addons Copyright © 2018 DragonByte Technologies Ltd.
All site content is protected by the Digital Millenium Act of 1998. Copyright©2001-2011 MAS Media Inc. and Extreme Visual Basic Forum. All rights reserved.
You may not copy or reproduce any portion of this site without written consent.