473,387 Members | 1,528 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,387 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 12643
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: 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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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.