Hi what's worng with the following code, the chages I made is only
change the DataSet but not the Data-Base:
try
{
DataSet ds = new DataSet();
OleDbDataAdapte r adapter = new OleDbDataAdapte r("Select * from
Employees", @"Provider=Micr osoft.Jet.OLEDB .4.0;Data Source=My.mdb") ;
adapter.Fill(ds , "Employees" );
ds.Tables["Employees"].Rows[0].BeginEdit();
ds.Tables["Employees"].Rows[0]["name"] = "X";
ds.Tables["Employees"].Rows[0].EndEdit();
ds.AcceptChange s();
adapter.Update( ds, "Employees" );
foreach(DataRow row in ds.Tables["Employees"].Rows)
{
Console.WriteLi ne(row["id"] + " " + row["name"]);
}
}
catch(Exception exp)
{
Console.WriteLi ne(exp.Message. ToString());
} 1 3144
On 10 Aug 2003 00:01:14 -0700, sh****@log-on.com (Shahar) wrote: Hi what's worng with the following code, the chages I made is only change the DataSet but not the Data-Base:
try { DataSet ds = new DataSet();
OleDbDataAdapte r adapter = new OleDbDataAdapte r("Select * from Employees", @"Provider=Micr osoft.Jet.OLEDB .4.0;Data Source=My.mdb") ;
adapter.Fill(ds , "Employees" );
ds.Tables["Employees"].Rows[0].BeginEdit(); ds.Tables["Employees"].Rows[0]["name"] = "X"; ds.Tables["Employees"].Rows[0].EndEdit();
ds.AcceptChange s(); adapter.Update( ds, "Employees" );
foreach(DataRow row in ds.Tables["Employees"].Rows) { Console.WriteLi ne(row["id"] + " " + row["name"]); } } catch(Exceptio n exp) { Console.WriteLi ne(exp.Message. ToString()); }
You are "updating" with the wrong dataset.
Prior to calling the AcceptChanges method, you need to call the
GetChanges method to return a dataset containing only the changed
records (inserted, deleted, or modified). That is the dataset that
Update should be called with, i.e.,
// change some fields...
// now get the changed records and apply them
DataSet changedData = ds.GetChanges() ;
if (changedData != null)
{
adapter.Update( changedData);
ds.AcceptChange s();
}
Oz This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Programatix |
last post by:
Hi,
I'm working on a project which includes WebServices and Windows Form
application.
The Windows Form application will call the WebServices to retrieve data from
database. The data will be returned as DataSet.
Now, here's the problem. On .NET Framework 1.1, if any rows in the dataset
returned contain errors (marked by calling the SetColumnError() method or
|
by: Programatix |
last post by:
Hi,
I'm working on a project which includes WebServices and Windows Form
application.
The Windows Form application will call the WebServices to retrieve data from
database. The data will be returned as DataSet.
Now, here's the problem. On .NET Framework 1.1, if any rows in the dataset
returned contain errors (marked by calling the SetColumnError() method or
|
by: theWizK |
last post by:
Hello all.
I have noticed that when I generate a strongly-typed dataset from an xml
schema that the DataTables that are generated have their constructors marked
as internal. What this means is when I try to instantiate one of the
strongly-typed tables from this dataset from a different assembly, I cannot.
Let me provide examples...
If I have a simple dataset like this:
|
by: Joerg M. Colberg |
last post by:
Hi all,
I have a problem when using a DataSet. I am using it to query a
SQLServer database as follows. In my code it looks like
SqlDataAdapter eDA = new SqlDataAdapter(sqlcmd);
// where sqlcmd is a SQL String
DataSet ds = new DataSet();
eDA.fill(ds);
|
by: Dennis |
last post by:
Hi, I am hoping I can get some help with a small problem I have run
into using C#. U have an XML file that I load into a Dataset and then
display this in a Datagrid. No problems doing this at all. I then use
a Dataview to filter this view using a keyword and I have no problems
with this either.
What I would like to do is to save this Dataview to a new Dataset so I
can save the reslts to a new file but here is where I am having the...
| |
by: Arne |
last post by:
How do I pass a dataset to a webservices? I need to submit a shoppingcart
from a pocket PC to a webservice.
What is the right datatype?
II have tried dataset as a datatype, but I can't get it to compile.
<WebMethod()> _
Public Function VerifySku(ByVal skus As XmlDataDocument) As DataSet
Test program :
Dim cartSet As DataSet
cartSet = ws.VerifySku(cartSet)
|
by: Bob Davies |
last post by:
Hi
I have a webservice that retrieves data from a database, this is then
returned to the calling client application built in windows forms within a
dataset, however upon attempting to create tablestyles to format any of the
columns within the datagrid, the exception "Can-not parent objects created
on one thread to objects created on another" or words to that effect.
I'm not too sure if what I said make sense, but i will add details to...
|
by: Carl Summers |
last post by:
I have a table in an Access database that has no sort applied in
Access. When I fill a dataset with data from that table (the entire
one dimensional table) my dataset is sorted differently than the
database. This would not be a problem, and really isn't a problem
except that it means I have to search the dataset each time I want to
find a particular record instead of just storing a variable. Which
brings me to a different question....
|
by: A_PK |
last post by:
I have problem databinding the DataGrid with DataView/DataSet after the
filter...
I create the following proceudre in order for user to filter as many as they
want, but the following code is only allow user to filter the first time,
when they tried the second time, the speficied cast error message will
prompt one....
I create a mydataset1 first, and the mydataset1 data source was getting from
DataGrid.DataSource.
|
by: Harry Strybos |
last post by:
Visual Studio 2005 - SP1 - VB.Net on WinXP SP2
I add a typed dataset to my solution and get the following errors :
Error 1 sub 'ReadXmlSerializable' cannot be declared 'Overrides' because it
does not override a sub in a base class.
C:\AAProjects.Net\TRM8\TRM8.UI\Reports\BillingReport.Designer.vb 125 29
TRM8.UI
Error 2 'Protected Overrides Function GetSchemaSerializable() As
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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...
|
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...
|
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...
|
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...
|
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();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
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...
| |