Update Doesn't Update
Update Doesn't Update
Update Doesn't Update
Update Doesn't Update
Update Doesn't Update
Update Doesn't Update Update Doesn't Update Update Doesn't Update Update Doesn't Update Update Doesn't Update Update Doesn't Update Update Doesn't Update Update Doesn't Update
Update Doesn't Update Update Doesn't Update
Update Doesn't Update
Go Back  Xtreme Visual Basic Talk > > > Update Doesn't Update


Reply
 
Thread Tools Display Modes
  #1  
Old 10-13-2014, 12:08 PM
sirmilt sirmilt is offline
Contributor
 
Join Date: Jan 2003
Location: Florida
Posts: 451
Angry 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
Try
Me.Validate()
Me.TblPasswordDetailsBindingSource.EndEdit()
Me.TblPasswordDetailsTableAdapter.Update(Me.CareTakerDataSet.tblPasswo rdDetails)
MsgBox("Update successful")

Catch ex As Exception
MsgBox(ex.ToString)
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.

Milt
Reply With Quote
  #2  
Old 02-24-2015, 08:26 AM
JustinCase2 JustinCase2 is offline
Junior Contributor
 
Join Date: Apr 2006
Posts: 324
Default 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.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Update Doesn't Update
Update Doesn't Update
Update Doesn't Update Update Doesn't Update
Update Doesn't Update
Update Doesn't Update
Update Doesn't Update Update Doesn't Update Update Doesn't Update Update Doesn't Update Update Doesn't Update Update Doesn't Update Update Doesn't Update
Update Doesn't Update
Update Doesn't Update
 
Update Doesn't Update
Update Doesn't Update
 
-->