473,765 Members | 2,059 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.ReadO nly = False
grdDetail.ReadO nly = False
bEdit.Text = "Save"
Else
Try
OleDbDataAdapte r1.Update(DSMas ter)
OleDbDataAdapte r2.Update(DSMas ter)
Catch ex As Exception
MsgBox("bEdit: Update failed" & vbCrLf & ex.Message)
End Try
grdMaster.ReadO nly = True
grdDetail.ReadO nly = 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 2524
Hi,

"N! Xau" <nx**@hotmail.c om> wrote in message
news:11******** *************@g 43g2000cwa.goog legroups.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 OleDbDataAdapte r'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 OleDbDataAdapte r 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.ReadO nly = False
grdDetail.ReadO nly = False
bEdit.Text = "Save"
Else
Try
OleDbDataAdapte r1.Update(DSMas ter)
OleDbDataAdapte r2.Update(DSMas ter)
Catch ex As Exception
MsgBox("bEdit: Update failed" & vbCrLf & ex.Message)
End Try
grdMaster.ReadO nly = True
grdDetail.ReadO nly = 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
21387
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 'System.InvalidOperationException' occurred in system.data.dll Additional information: Update requires a valid InsertCommand when passed DataRow collection with new rows.
7
3364
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 in the good way, cause I build that code from a book example, but nothing works. I HAVE THIS CODE TO SAVE THE CHANGE OF THE DATASET dstPlant.Tables("plant").Rows(intEditRow)("latin_name") = "KLHJJKJKJKHHHHHH"
4
1494
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 and update commands automatically for the dataadapter. I think those database tables had no more than 10 or 12 fields. Then to save the changes in the datagrid to the database, I simply evoked the dataadapter update command. No problems. ...
4
2313
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, Len(Application.ExecutablePath) - 14)
1
1537
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 make a call to: myTableBindingSource.AddNew(); and this inserts a blank row.
2
11160
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 dataset to the project and drag a datatable from server explorer onto the dataset design surface. In the configuration wizard, under advanced options the "refresh data table" is disabled ie I am not able to check it (note if the source db is sql...
1
2867
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 from a dataset: Me.T_1TableAdapter.Fill(Me.T_1DateSet.T_1)
3
3094
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 generated strong typed dataset and binding. And here is my problem. I try to update the database with the new (changes) values from DataGridView:
0
10007
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9835
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8832
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7379
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6649
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5276
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5423
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3532
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2806
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.