By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,380 Members | 3,074 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,380 IT Pros & Developers. It's quick & easy.

Saving Data when modified

daniel aristidou
100+
P: 491
Hi guys im stuck in vb08 again......

Im trying to save the database after editing with a datagrid.
It saves ok when a new record has been added but not when existing data has been modified.

This is the code im using
Expand|Select|Wrap|Line Numbers
  1. Try
  2.  Me.Validate()
  3.  Me.Customerbindingsource.endedit()
  4.  Me.customertableadapter.update(me.fortedataset1.Customers)
  5.  msg("Data saved")
  6. Catch ex as exception
  7.  Msg("saved Failed")
  8.  e.cancel = True
  9. End try
The error occurs on the Me.Customertableadapter.update(me.fortedataset1.Cu stomers) line
The default error message is:
"Update requires a valid updatecommand when passed datarow with modified rows"

Any solution?

Daniel(~_~)
Jan 5 '08 #1
Share this Question
Share on Google+
8 Replies


QVeen72
Expert 100+
P: 1,445
Hi,

Check the Update Command for the Customeradapter.
usually, "Update" Statements are not built automatically, you have to Create a New for Update with proper SQL Syntax..

REgards
Veena
Jan 5 '08 #2

daniel aristidou
100+
P: 491
Hi,

Check the Update Command for the Customeradapter.
usually, "Update" Statements are not built automatically, you have to Create a New for Update with proper SQL Syntax..

REgards
Veena
Then what does the
Me.Customerstableadapter.Update(etc)
Do?
Jan 5 '08 #3

QVeen72
Expert 100+
P: 1,445
Hi,

Post here , What is your Update SQL Statement...?
May be, Update Statement is there but there is no proper "Where Conditions"..
Its better if Where Condition is based on the PK of the table..

REgards
Veena
Jan 5 '08 #4

daniel aristidou
100+
P: 491
Hi,

Post here , What is your Update SQL Statement...?
May be, Update Statement is there but there is no proper "Where Conditions"..
Its better if Where Condition is based on the PK of the table..

REgards
Veena
I cannot find a statement anywhere except for the fill data statement which is used to copy the records from the dataset to the adapter.
Jan 5 '08 #5

QVeen72
Expert 100+
P: 1,445
Hi,

Right-Click the adatpter object >> Edit Queries in dataSet Designer
Select Adapter RightClick >> Add Queries >> Next >> Select OptionUpdate
>> Next
Check What is the Updte Statement..

Regards
Veena
Jan 5 '08 #6

daniel aristidou
100+
P: 491
Hi,

Right-Click the adatpter object >> Edit Queries in dataSet Designer
Select Adapter RightClick >> Add Queries >> Next >> Select OptionUpdate
>> Next
Check What is the Updte Statement..

Regards
Veena
The Update statement is simply "update"
Jan 5 '08 #7

daniel aristidou
100+
P: 491
The Update statement is simply "update"
But how do i enforce the statement
Jan 5 '08 #8

daniel aristidou
100+
P: 491
But how do i enforce the statement
I moved on to this
Dim adpt as tableadapter
adpt.updatecommand() But im stuck on that......it wont let me use it. and seems to return "Nothing"

Also as per The Sql Statment. I dont know sql at all. can some one help me create an update statement It says whenever i try ........."token line 1, tokenline to 25"
Jan 5 '08 #9

Post your reply

Sign in to post your reply or Sign up for a free account.