472,993 Members | 1,959 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

dataset update

Hi,

Please check these lines:

DataSet dataSet = new DataSet();
dataAdapter.Fill(dataSet, "mytable");
DataRow row;
row = dataSet.Tables[0].Rows[0];
row.BeginEdit();
row[0] = "555";
row.EndEdit();
//dataSet.AcceptChanges();
dataAdapter.Update(dataSet, "mytable");

I got this error message on dataAdapter.Update line:

Additional information: Update requires a valid UpdateCommand when passed
DataRow collection with modified rows.

with dataSet.AcceptChanges() I don't get error message but the database is
not really changed. when I use datagrid and use dataAdapter.Update() it
works. what's the problem?

my other question, what's the easiest way to edit a value of a field in a
table?

thanks
Nov 16 '05 #1
2 12609
Tue. Aug. 31, 2004 11:50 AM PT

See the MSDN documentation, for the SqlDataAdapter, You need to pass four
commands SqlCommand object, which also has the connecton object which
connects to your database, SELECT, INSERT, UPDATE, DELETE. to your data
adapter object, inorder to update PHYSICALLY into your database, otherwise,
with dataset AcceptChanges, changes will be made only in the DataSet, when
you quit the application these changes be loss. Read the MSDN documentation
about updation dataset, and the data adapter.

Good Luck !

"Mojtaba Faridzad" <mf*******@hotmail.com> wrote in message
news:Oz**************@TK2MSFTNGP10.phx.gbl...
Hi,

Please check these lines:

DataSet dataSet = new DataSet();
dataAdapter.Fill(dataSet, "mytable");
DataRow row;
row = dataSet.Tables[0].Rows[0];
row.BeginEdit();
row[0] = "555";
row.EndEdit();
//dataSet.AcceptChanges();
dataAdapter.Update(dataSet, "mytable");

I got this error message on dataAdapter.Update line:

Additional information: Update requires a valid UpdateCommand when passed
DataRow collection with modified rows.

with dataSet.AcceptChanges() I don't get error message but the database is not really changed. when I use datagrid and use dataAdapter.Update() it
works. what's the problem?

my other question, what's the easiest way to edit a value of a field in a
table?

thanks

Nov 16 '05 #2
DataRow has a flag of his state: DataRow.RowState
The DataAdapter use this flag to know if it need to do nothing a delete an
insert or an update.
If you call the DataRow.AcceptChanges() you reset this flag and the
DataAdapter does nothing.

But your problem is something else, your DataAdpater don't have an
UpdataCommand!!
DataAdapter.UpdateCommand=new SqlCommand("UPDATE ..... ",...);

"Mojtaba Faridzad" <mf*******@hotmail.com> schrieb im Newsbeitrag
news:Oz**************@TK2MSFTNGP10.phx.gbl...
Hi,

Please check these lines:

DataSet dataSet = new DataSet();
dataAdapter.Fill(dataSet, "mytable");
DataRow row;
row = dataSet.Tables[0].Rows[0];
row.BeginEdit();
row[0] = "555";
row.EndEdit();
//dataSet.AcceptChanges();
dataAdapter.Update(dataSet, "mytable");

I got this error message on dataAdapter.Update line:

Additional information: Update requires a valid UpdateCommand when passed
DataRow collection with modified rows.

with dataSet.AcceptChanges() I don't get error message but the database is not really changed. when I use datagrid and use dataAdapter.Update() it
works. what's the problem?

my other question, what's the easiest way to edit a value of a field in a
table?

thanks

Nov 16 '05 #3

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

Similar topics

2
by: Niyazi | last post by:
Hi, I have not understand the problem. Before all the coding with few application everything worked perfectly. Now I am developing Cheque Writing application and when the cheque is clear the...
4
by: Oscar Thornell | last post by:
Hi, I have a relativley large/complex typed dataset that contains 7-8 tables and some supporting relational tables (lookups) for many-to-many relations. A good exampel would be a dataset that...
1
by: Mike Hnatt | last post by:
I'm baffled. My data store (database) is not updating with a refreshed dataset. Here's what is going on: 1) Create a dataset from a table in a database. 2) Create a copy of this dataset and...
0
by: Vijay Balki | last post by:
I am fetching data in DataSet - myDataSet, from a remote database using a Web Service in my VB.NET client..Once I fetch it I store the data in XML file (myXMLFile) using the WriteXML method of the...
9
by: Kevin Hodgson | last post by:
I'm experiencing a strange Dataset Update problem with my application. I have a dataset which has a table holding a set of customer information records. (address, contact, info, etc.) I have a...
3
by: PAUL | last post by:
Hello, I have 2 datasets I am trying to update. The parent table seems to update fine but when I go update the chiled table I get an error message that says I need a related record in the parent...
2
by: Scotty | last post by:
I get stuck to write an update, insert and delete command, i am looking for some help to start Whats the best way to update 2 tables toe the database (Access) below my code used to load my...
0
by: BVA3105 | last post by:
i update a database with a dataset and a SqlAdapter with success but when i clear and refill my dataset i always retreive the old values. I have to wait for 5 seconds to get the corrects values. ...
1
by: Krish2007 | last post by:
Hi, Consider the following scenario I have a Database source i had filled in my dataset with the help of Dataadapter after working on the dataset i want the data source to be updated back with...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
3
SueHopson
by: SueHopson | last post by:
Hi All, I'm trying to create a single code (run off a button that calls the Private Sub) for our parts list report that will allow the user to filter by either/both PartVendor and PartType. On...

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.