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

Comparing Dataset Question

how come unchanged always true even if data changed

This code come from my saving button:

============================================
DataSet ds1 = new DataSet();
DataSet ds2 = new DataSet();
DataSet ds3 = new DataSet();

//Static Dataset which contain values when my form load
ds1.Tables.Add(ModelSelectionGlobal.dsModelSelecti on.Tables["C"].Copy());
//this datatable contain the value of all controls when saving
ds2.Tables.Add(dt.Copy());

ds3.Merge(ds1);
ds3.AcceptChanges();
//now ds1 supposed to be the reference
ds3.Merge(ds2);
//ds2 contain the same structure as ds1 but may have different values

//this test should tell me is ds2 changed ds1 but it does always
return true
if (ds3.HasChanges(DataRowState.Unchanged) == false)
{
for (int y = 0; y <= 31; y++)
{
//filling data with datarows of dt
ModelSelectionGlobal.dsModelSelection.Tables["C"].Rows[0]
[y] = dr[y];
}
}
================================================== =====

what im doing wrong here ?

Oct 19 '07 #1
5 1829
Hi Franck,
if (ds3.HasChanges(DataRowState.Unchanged) == false)
I think instead you should try:
if (ds3.HasChanges() == false)

and you can actually skip the comparing to 'false':
if (!ds3.HasChanges())
Hope this helps :)
--
_____________
Adam Bieganski
http://godevelop.blogspot.com
"Franck" wrote:
how come unchanged always true even if data changed

This code come from my saving button:

============================================
DataSet ds1 = new DataSet();
DataSet ds2 = new DataSet();
DataSet ds3 = new DataSet();

//Static Dataset which contain values when my form load
ds1.Tables.Add(ModelSelectionGlobal.dsModelSelecti on.Tables["C"].Copy());
//this datatable contain the value of all controls when saving
ds2.Tables.Add(dt.Copy());

ds3.Merge(ds1);
ds3.AcceptChanges();
//now ds1 supposed to be the reference
ds3.Merge(ds2);
//ds2 contain the same structure as ds1 but may have different values

//this test should tell me is ds2 changed ds1 but it does always
return true
if (ds3.HasChanges(DataRowState.Unchanged) == false)
{
for (int y = 0; y <= 31; y++)
{
//filling data with datarows of dt
ModelSelectionGlobal.dsModelSelection.Tables["C"].Rows[0]
[y] = dr[y];
}
}
================================================== =====

what im doing wrong here ?

Oct 19 '07 #2
On Oct 19, 10:21 am, Adam Bieganski <abieganski(at)gmail.comwrote:
Hi Franck,
if (ds3.HasChanges(DataRowState.Unchanged) == false)

I think instead you should try:
if (ds3.HasChanges() == false)

and you can actually skip the comparing to 'false':
if (!ds3.HasChanges())

Hope this helps :)
--
_____________
Adam Bieganskihttp://godevelop.blogspot.com

"Franck" wrote:
how come unchanged always true even if data changed
This code come from my saving button:
============================================
DataSet ds1 = new DataSet();
DataSet ds2 = new DataSet();
DataSet ds3 = new DataSet();
//Static Dataset which contain values when my form load
ds1.Tables.Add(ModelSelectionGlobal.dsModelSelecti on.Tables["C"].Copy());
//this datatable contain the value of all controls when saving
ds2.Tables.Add(dt.Copy());
ds3.Merge(ds1);
ds3.AcceptChanges();
//now ds1 supposed to be the reference
ds3.Merge(ds2);
//ds2 contain the same structure as ds1 but may have different values
//this test should tell me is ds2 changed ds1 but it does always
return true
if (ds3.HasChanges(DataRowState.Unchanged) == false)
{
for (int y = 0; y <= 31; y++)
{
//filling data with datarows of dt
ModelSelectionGlobal.dsModelSelection.Tables["C"].Rows[0]
[y] = dr[y];
}
}
================================================== =====
what im doing wrong here ?
This works but i have a second issue.
when i merge ds2 inside ds3 i thought it would overwrite ds1 thats
already there but it's not. even if the tables have the same name it
does not replace but create another table, so in my ds3 the ds1 is :
ds3.table[0] and ds2 is ds3.table[1]. that's why haschanges say it
havent been changed.

Oct 19 '07 #3
"Franck" wrote:
On Oct 19, 10:21 am, Adam Bieganski <abieganski(at)gmail.comwrote:
Hi Franck,
if (ds3.HasChanges(DataRowState.Unchanged) == false)
I think instead you should try:
if (ds3.HasChanges() == false)

and you can actually skip the comparing to 'false':
if (!ds3.HasChanges())

Hope this helps :)
--
_____________
Adam Bieganskihttp://godevelop.blogspot.com

"Franck" wrote:
how come unchanged always true even if data changed
This code come from my saving button:
============================================
DataSet ds1 = new DataSet();
DataSet ds2 = new DataSet();
DataSet ds3 = new DataSet();
//Static Dataset which contain values when my form load
ds1.Tables.Add(ModelSelectionGlobal.dsModelSelecti on.Tables["C"].Copy());
//this datatable contain the value of all controls when saving
ds2.Tables.Add(dt.Copy());
ds3.Merge(ds1);
ds3.AcceptChanges();
//now ds1 supposed to be the reference
ds3.Merge(ds2);
//ds2 contain the same structure as ds1 but may have different values
//this test should tell me is ds2 changed ds1 but it does always
return true
if (ds3.HasChanges(DataRowState.Unchanged) == false)
{
for (int y = 0; y <= 31; y++)
{
//filling data with datarows of dt
ModelSelectionGlobal.dsModelSelection.Tables["C"].Rows[0]
[y] = dr[y];
}
}
================================================== =====
what im doing wrong here ?

This works but i have a second issue.
when i merge ds2 inside ds3 i thought it would overwrite ds1 thats
already there but it's not. even if the tables have the same name it
does not replace but create another table, so in my ds3 the ds1 is :
ds3.table[0] and ds2 is ds3.table[1]. that's why haschanges say it
havent been changed.
I think you can get rid of the first 2 datasets completely:

ds3.Tables.Add(ModelSelectionGlobal.dsModelSelecti on.Tables["C"].Copy());
ds3.AcceptChanges();
ds3.Merge(dt.Copy());

If this doesn't help - try to explicitly set the names of the tables
returned by the Copy() methods:

DataTable dt1 = ModelSelectionGlobal.dsModelSelection.Tables["C"].Copy();
dt1.TableName = "Table1";
ds3.Tables.Add(dt1);
ds3.AcceptChanges();
dt1 = dt.Copy();
dt1.TableName = "Table1";
ds3.Merge(dt1);

Cheers,
--
_____________
Adam Bieganski
http://godevelop.blogspot.com

Oct 19 '07 #4
On Oct 19, 12:21 pm, Adam Bieganski <abieganski(at)gmail.comwrote:
"Franck" wrote:
On Oct 19, 10:21 am, Adam Bieganski <abieganski(at)gmail.comwrote:
Hi Franck,
if (ds3.HasChanges(DataRowState.Unchanged) == false)
I think instead you should try:
if (ds3.HasChanges() == false)
and you can actually skip the comparing to 'false':
if (!ds3.HasChanges())
Hope this helps :)
--
_____________
Adam Bieganskihttp://godevelop.blogspot.com
"Franck" wrote:
how come unchanged always true even if data changed
This code come from my saving button:
============================================
DataSet ds1 = new DataSet();
DataSet ds2 = new DataSet();
DataSet ds3 = new DataSet();
//Static Dataset which contain values when my form load
ds1.Tables.Add(ModelSelectionGlobal.dsModelSelecti on.Tables["C"].Copy());
//this datatable contain the value of all controls when saving
ds2.Tables.Add(dt.Copy());
ds3.Merge(ds1);
ds3.AcceptChanges();
//now ds1 supposed to be the reference
ds3.Merge(ds2);
//ds2 contain the same structure as ds1 but may have different values
//this test should tell me is ds2 changed ds1 but it does always
return true
if (ds3.HasChanges(DataRowState.Unchanged) == false)
{
for (int y = 0; y <= 31; y++)
{
//filling data with datarows of dt
ModelSelectionGlobal.dsModelSelection.Tables["C"].Rows[0]
[y] = dr[y];
}
}
================================================== =====
what im doing wrong here ?
This works but i have a second issue.
when i merge ds2 inside ds3 i thought it would overwrite ds1 thats
already there but it's not. even if the tables have the same name it
does not replace but create another table, so in my ds3 the ds1 is :
ds3.table[0] and ds2 is ds3.table[1]. that's why haschanges say it
havent been changed.

I think you can get rid of the first 2 datasets completely:

ds3.Tables.Add(ModelSelectionGlobal.dsModelSelecti on.Tables["C"].Copy());
ds3.AcceptChanges();
ds3.Merge(dt.Copy());

If this doesn't help - try to explicitly set the names of the tables
returned by the Copy() methods:

DataTable dt1 = ModelSelectionGlobal.dsModelSelection.Tables["C"].Copy();
dt1.TableName = "Table1";
ds3.Tables.Add(dt1);
ds3.AcceptChanges();
dt1 = dt.Copy();
dt1.TableName = "Table1";
ds3.Merge(dt1);

Cheers,
--
_____________
Adam Bieganskihttp://godevelop.blogspot.com
nothing works,

gonna do if statement with and compare all my fields one by one this
im sure it works.

Oct 19 '07 #5
Frank,

AFAIK does merge not change the rowstates, the merge is merging rows (and
adding and changing new ones for old ones, however is not affecting the
fields).

Cor

Oct 20 '07 #6

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

Similar topics

1
by: Eric | last post by:
Hello, I am trying to write a webservice to compare 2 datasets, one recieved from a client, and the other taken from a database on the webserver. Sofar, I have had little success in...
3
by: JamesWilce | last post by:
Hey, I am stuck on this little problem, I have a database which I use to fill a dataset when my application loads, however at certain intervals Im filling another dataset using the same...
0
by: Elliot M. Rodriguez | last post by:
I can accomplish this relatively easily but inefficiently, and it seems like a hack, but I cant think of a better workaround. Hopefully someone else here can. My task is to perform an update on...
19
by: Will Lastname | last post by:
In one of the applications that I'm working on I have 2 sets of functions that build different datasets. Imagine 4 columns in a datagrid. Inside those 4 columns I have nested datalists. Two of...
11
by: Jeff | last post by:
Hi - I'm experiencing a strange problem when comparing 2 guids. In my trial, they're not equal. When I step through the (VB.NET) code, they are evaluated as equal, and when I enter the...
22
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...
4
by: Frank | last post by:
Hello, Developing an app where the user fills out a sometimes quite lengthy form of chkboxes, txtboxes, radbtns, etc. User responses are saved to a mySql db, which the user can later edit. When...
5
by: Frank | last post by:
Hello All, I am working on a vb.net app where I need to compare to 2 datatables and determine if a string exists in one or both. The first dt is filled from the db. A form is loaded and the...
2
by: Nick Hodge \(MVP\) | last post by:
Hi I currently have a gridview connected to a SQLDatasource. (This data comes from a remote iSeries). It shows catalogue sales as they build during the day (works great). I have a local SQL...
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: 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
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
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...
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
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
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...

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.