Académique Documents
Professionnel Documents
Culture Documents
@-VBForums
Remember Me?
New Posts FAQ Calendar Forum Actions Quick Links Advanced Search
VBForums Visual Basic Visual Basic .NET [RESOLVED] Tableadapter Update Command only works once!?@
If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to
proceed. To start viewing messages, select the forum that you want to visit from the selection below. Featured
Results 1 to 11 of 11 * Storing
Data in the
Cloud
Thread: [RESOLVED] Tableadapter Update Command only works once!?@ Learn step-
Tweet by-step how to
setup data in
Thread Tools Display the cloud and
use it within
#1 an application.
Apr 4th, 2008, 04:48 PM
* Accessing
beamer4lyf Cloud Data
[RESOLVED] Tableadapter Update Command only works once!?@ using an
Thread Starter OData Web
New Member
I have a SQL database created in VS2005 (not express ed.) I have one table with Name and Age Fields. I Service
have two text boxes databound to these two columns in my table. On the command click of a button on Learn to
Join Date: Apr 2008
my form i have the following code. build a web
Posts: 15
service and an
bindingsource1.endedit () application
tabeadapter.update(mydataset.mytablename) that consumes
your data that
is stored in the
in a try catch block.
cloud.
i can add the rows to the database but when i go to update the row after i have made a change i get an * Windows
error. the error states that i called the update command incorrectly. the weird part is that this works the Mobile
first time i add something to the database using the Development
Center
bindingsource1.addnew CodeGuru's
tableadapter.update(mydataset.mytablename) Windows
Mobile
it adds the row to the database, but if i make a change to that row, i cannot call the update command Development
again without getting an error. Center
provides
any help is appreciated. I will post the code later when i get home. articles on
building
Thanks! Modern
Windows
Store Apps
Reply With Quote and more.
Share
on
* HTML5
Google+ Development
Apr 4th, 2008, 09:47 PM #2 Center
Our portal
jmcilhinney for articles,
Re: Tableadapter Update Command only works once!?@
.NUT videos, and
Tell us EXACTLY what the error message says. news on
HTML5, CSS3,
and JavaScript
beamer4lyf
Re: Tableadapter Update Command only works once!?@
Thread Starter
New Member
Code:
Join Date: Apr 2008 Try
Me.Validate()
Posts: 15
Me.NameBindingSource.EndEdit()
Me.NameTableAdapter.Update(Me.DsTest.name)
MsgBox("Update successful")
Catch ex As Exception
MessageBox.Show("update failed")
End Try
the Error i receive is a system.invalidoperationexection... reads " Update requires a valid UpdateCommand
when passed DataRow collection with modified rows." and the following line of code is highlighted..
"Me.NameTableAdapter.Update(Me.DsTest.name)"
http://www.vbforums.com/showthread.php?516858-RESOLVED-Tableadapter-Update-Command-only-works-once! 1/5
7/3/2016 [RESOLVED] Tableadapter Update Command only works once!?@-VBForums
the help describes the error with the following, however i feel as though i am simply updating the modified
rows to the database after calling the end edit for the binding source. The update command works the
first time, but fails the second time.
"TableAdapters require valid UPDATE, INSERT, and DELETE commands to perform a successful save
operation.
TableAdapters generate INSERT, UPDATE, and DELETE statements based on the original SELECT
statement entered into the wizard. In some situations, the SELECT statement does not provide enough
information for the adapter to generate the commands necessary to create the INSERT, UPDATE, and
DELETE commands required for a successful save. This often occurs when the database table does not
have a primary key column, or the SELECT command uses JOINS. For more information, see How to: Edit
TableAdapters."
thanks!
beamer4lyf
Re: Tableadapter Update Command only works once!?@
Thread Starter
New Member The more wordy version of the error:
jmcilhinney
Re: Tableadapter Update Command only works once!?@
.NUT
This is why you need to provide the error message to us that the IDE provides to you. They are a
diagnostic tool and if you want us to diagnose the issue then we need that information. In this case it's
all we need:
Join Date: May 2005 Update requires a valid UpdateCommand when passed DataRow collection with modified rows.
Location: Sydney, Australia
Posts: 92,853
Your TableAdapter has no UpdateCommand, which suggests that the Data Source Wizard was unable to
generate one. That would happen because either the query contains a JOIN of two or more tables or else
the query doesn't return a primary key.
Does this TableAdapter correspond directly to a table in the database? Does that table have a primary
key? If not then how is the system to uniquely identify the records in order to know which one to
update? The same goes for deleting.
If you do need to update the database using such a TableAdapter that was generated from either a join,
a table with no primary key or query that returns no primary key then it's up to you to create the
UpdateCommand and DeleteCommand yourself, explicitly identifying the records uniquely so that the
correct ones get updated and deleted.
2007-2016
http://www.vbforums.com/showthread.php?516858-RESOLVED-Tableadapter-Update-Command-only-works-once! 2/5
7/3/2016 [RESOLVED] Tableadapter Update Command only works once!?@-VBForums
but when i click finish and then go to view the dataset in the designer window, i see only a fill, get data
statement
so i right click on the tableadapter and select properties to see what we have there.. it appears
everything is checked appropriately..
so then i go to the add query builder to see if i cant add the appropriate query. after running the wizard
and selecting to have valid insert, update and delete commands,
I STILL have a fill, get data statement and nothing else... except when i look at the properties of the
adapter, i see valid update and insert and delete commands...
I do have a primary key set for my table.. is this correctly done? do i need to do it for the dataset when i
create it? My impression was that the dataset becomes an in memory copy of the datatable.. thus taking
the key relationships as well..
i follow the examples online to the T and yet i still end up with this difference.. Please help guide me
towards correcting this problem. Thank you in advance for your dedication to my increasing my
knowledge of this problem.
-B
jmcilhinney
Re: Tableadapter Update Command only works once!?@
.NUT
OK, now you're posting the same stuff in two threads and one of them's not even yours. One thread per
topic and one topic per thread please. It's a waste of my time, your time and anybody else who might be
trying to track down the same information if the same question is being answered in multiple threads.
2007-2016
beamer4lyf
Re: Tableadapter Update Command only works once!?@
Thread Starter
New Member my apologies. I will forward any responses to what i have posted in the other thread to this thread as it
is mine. The double posting was unintentional.
Join Date: Apr 2008
Posts: 15
beamer4lyf
Re: Tableadapter Update Command only works once!?@
Thread Starter
New Member close up of the code generated..
http://www.vbforums.com/showthread.php?516858-RESOLVED-Tableadapter-Update-Command-only-works-once! 3/5
7/3/2016 [RESOLVED] Tableadapter Update Command only works once!?@-VBForums
why only fill, getby data shows up in query list when its in the properties of the table adapter...?
jmcilhinney
Re: Tableadapter Update Command only works once!?@
.NUT
Because they are the only methods that execute queries. The Update method is what executes the
DeleteCommand, InsertCommand and UpdateCommand, which are not queries. That query list shows all
the methods that correspond to SELECT statements. You can add more queries if you want to allow the
user to specify different combinations of parameters to filter the data. there will still only ever be one
Join Date: May 2005 DeleteCommand, one InsertCommand and one UpdateCommand though, and they will always be executed
Location: Sydney, Australia by calling the Update method.
Posts: 92,853
2007-2016
beamer4lyf
Re: Tableadapter Update Command only works once!?@
Thread Starter
New Member Yes. Thank you JMCillhinney. I was investigating the issue further and decided to try and add a new
Query to contain the update method. I went to the designer window and selected the table adapter and
Join Date: Apr 2008 right clicked to show add -> Query. I selected use SQL statement then selected update. Now at this
Posts: 15 point i noticed that the code was already filled in for me with a valid SQL statment on how to select and
update the rows according to their key value. The difference here is that in my original dataset i didnt
have this pre-populated code. when creating that dataset i remember i only selected tables when asked
what i wanted to have the dataset contain. this time i selected everything, including stored proceedures
and then i added them manually and it works. I test run the program and no error. I ran a build and tried
it out of VS and it worked as well.
Thank you so much for your guidance. And sorry again for the double posting.
VBForums Visual Basic Visual Basic .NET [RESOLVED] Tableadapter Update Command only works once!?@
Posting Permissions
You may not post new threads BB code is On
You may not post replies Smilies are On
You may not post attachments [IMG] code is On
You may not edit your posts [VIDEO] code is On
HTML code is Off
Forum Rules
http://www.vbforums.com/showthread.php?516858-RESOLVED-Tableadapter-Update-Command-only-works-once! 4/5
7/3/2016 [RESOLVED] Tableadapter Update Command only works once!?@-VBForums
Copyright 2016 QuinStreet Inc. All Rights Reserved.
All times are GMT -5. The time now is 11:53 PM.
http://www.vbforums.com/showthread.php?516858-RESOLVED-Tableadapter-Update-Command-only-works-once! 5/5