473,388 Members | 1,230 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

Update requires a valid command

Hi all,

I created a dataform using the wizard, everything works fine.
I set both grids to readonly = true, and added a button to switch this
property and save modifications to db. I didn't make any other changes
to the auto-generated code.
But I keep having an error:
"Update requires a valid update command when passed DataRow collection
with modified rows"

Button's click code is:

If bEdit.Text = "Edit" Then
grdMaster.ReadOnly = False
grdDetail.ReadOnly = False
bEdit.Text = "Save"
Else
Try
OleDbDataAdapter1.Update(DSMaster)
OleDbDataAdapter2.Update(DSMaster)
Catch ex As Exception
MsgBox("bEdit: Update failed" & vbCrLf & ex.Message)
End Try
grdMaster.ReadOnly = True
grdDetail.ReadOnly = True
bEdit.Text = "Edit"
End If

thanks for help

N! Xau

Keep in mind the power of ANTANI
http://ilovemiliofede.altervista.org

Nov 21 '05 #1
1 2508
Hi,

"N! Xau" <nx**@hotmail.com> wrote in message
news:11*********************@g43g2000cwa.googlegro ups.com...
Hi all,

I created a dataform using the wizard, everything works fine.
I set both grids to readonly = true, and added a button to switch this
property and save modifications to db. I didn't make any other changes
to the auto-generated code.
But I keep having an error:
"Update requires a valid update command when passed DataRow collection
with modified rows"
Check if you have two OleDbCommand's for update on the form and check if
they are assigned to the OleDbDataAdapter's (see designer generated code).

The wizard will not create an update command for a table that doesn't have a
primary key. It won't work with db views(joins) either.

You can setup/refresh each OleDbDataAdapter individually by right-clicking
on them and select "configure dataadapter", this way it will warn you if it
couldn't create some of the commands.
HTH,
Greetings

Button's click code is:

If bEdit.Text = "Edit" Then
grdMaster.ReadOnly = False
grdDetail.ReadOnly = False
bEdit.Text = "Save"
Else
Try
OleDbDataAdapter1.Update(DSMaster)
OleDbDataAdapter2.Update(DSMaster)
Catch ex As Exception
MsgBox("bEdit: Update failed" & vbCrLf & ex.Message)
End Try
grdMaster.ReadOnly = True
grdDetail.ReadOnly = True
bEdit.Text = "Edit"
End If

thanks for help

N! Xau

Keep in mind the power of ANTANI
http://ilovemiliofede.altervista.org

Nov 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Jon S via DotNetMonster.com | last post by:
Hi all, I'm having a problem updating a simple change I've made to a Access 2000 table through databinding. The error I get is : An unhandled exception of type...
7
by: Jean Christophe Avard | last post by:
Hi! I have a dataset that retreive all the item information from the database. I need to be able to edit them, in the dataset and in the database. I have this code, could anyone tell me if I'm...
4
by: William LaMartin | last post by:
In the past, I have filled a datagrid with data from an Access database table using a data adapter and dataset, where I used the OleDbCommandBuilder to have the program create the insert, delete...
4
by: George | last post by:
Hi all, I am having trouble with updating my data in an Access database. here is my code: Imports System.Data.OleDb Dim AppPath As String = Mid(Application.ExecutablePath, 1,...
1
by: Shaun O''Callaghan | last post by:
Hi All, I have a typed dataset on a Windows form on Smart Device Application that displays data from a Sql Server Mobile database. The problem is, whenever I want to add a new record I first...
2
by: travhale | last post by:
in a new project using .net 2005, c#. getting err message "Update requires a valid UpdateCommand when passed DataRow collection with modified rows." source RDBMS is oracle 8i. I add a new...
1
by: mikalush | last post by:
is anyone know if i can update access database with dataset in the vs 2005 express? really imortant to me. i need to know maybe i just wasting my time! i've a datagridView that get is data...
3
by: =?Utf-8?B?THVib21pcg==?= | last post by:
Hi, I have a DataGridView that displays data from one table from database. I didn’t implement any my code, I just used wizard to do all the work with DatagridView populating. Visual Studio...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.