473,406 Members | 2,377 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,406 software developers and data experts.

DataGrid.GetChanges and DataSet.WriteXml

I am writing a DataBase Client/Server pair of applications in C#. The
client registers a query, the server populates a dataset and its
contents sent via XML to be displayed in the client DataGrid. This
works fine.
When the data is modified in the client DataGrid, the
DataGrid.GetChanges call populates the change dataset which is
transferred back to the server and the DataAdapter is Updated. This is
where I am having a couple of problems:
1. Any deletes are not captured in the change dataset XML.
2. There is no difference between modifications and additions in the
change dataset XML.

2. can be demonstrated in that if a record is edited in the client a
new record is inserted on the server side.

Your help is appreciated.
Nov 15 '05 #1
1 2566
Hi paul
to issue one:

this keep the state as deleted ( DataRowState.Deleted) you have to redelete
it
here is an example
for( int idx = 0; idx < r.Count; idx++ )
{
DataRow row = mytable.Rows[ idx ];
if( row.RowState == DataRowState.Deleted )
{
if( row[ mycolumn, DataRowVersion.Original ].ToString()== "12.2" )
{
r.RemoveAt( idx );
idx--;
}
}
else
{
if( row[ mycolumn].ToString() == "12.2" )
{
r.RemoveAt( idx );
idx--;
}
}
}

to issue two:
you have to define a primary key in each table in both sides ( clint and
server ) . this is the way by which the ado can differenciate between a new
row and an edited row .
for example :
if we have name id and age table with no primary key
how would ado know that mark 2
23 is the edited values of mark 2 25 and not
a new row!!!
however if we know that id 2 is the id then we can know that it is an
edited values of the same row.
to create a primary key we set the primary key properity to an array of
datacolumns
this is an example of table creation with a primary key
DataTable US = new DataTable("us");
DataColumn name = new DataColumn("name");
DataColumn ID = new DataColumn("ID");
DataColumn Ext = new DataColumn("Phone Ext");
US.Columns.Add(name);
US.Columns.Add(ID);
US.Columns.Add(Ext);
US.PrimaryKey =new DataColumn[]{ ID};

hope this would help
Nov 15 '05 #2

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

Similar topics

6
by: BFX | last post by:
Hi All, I have datagrid with binding on dataset this.grdMachineType.DataMember = "MachineTypes"; this.grdMachineType.DataSource = this.dsMachineTypes; After append new row in datagrid i...
0
by: Jan Keller | last post by:
Hello all, I am using an XmlTextReader and a DataSet to populate a DataGrid: ds = New DataSet xr = New XmlTextReader(path) ds.ReadXml(xr) xr.Close() dv = New DataView(ds.Tables.Item(0))
2
by: Frosty | last post by:
Howto make datagrid enforce rules of xml schema? Created xml schema in the designer. Constraints created there using the following <xs:simpleType name="zipcode"><xs:restriction...
0
by: Davewadd | last post by:
I'm having an odd problem with a datagrid in a c# program. The program maintains a schedule of jobs that need to be run. As jobs run, the status and next run date/time info are updated in a SQL...
1
by: Marty | last post by:
In winforms, I can bind a datagrid to a dataset. When the user wants to submit changes, it's easy to see what has changed with the DataSet "GetChanges" method. In ASP.Net, I can create the...
20
by: MadCrazyNewbie | last post by:
Hey group, I keep getting the following error: "An unhandled exception of type 'System.IndexOutOfRangeException' occurred in system.data.dll Additional information: There is no row at...
17
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...
1
by: kcakebread | last post by:
Using VB 2005, I have a strongly typed dataset (from a .xsd file in my project). When I load data into this dataset, the immediate window shows: ?ds.TableX(0).IstheFieldNull True So,...
1
by: Bmack500 | last post by:
I'm using the following subroutine. The two different XML files are identical with the exception of three additional records in the second one. One has 450 records, and the other has 453. After...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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,...

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.