473,406 Members | 2,769 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.

Event not firing

Hi there,

Does anyone know why the "ColumnChanged" event isn't fired when "Merge()" is
called below. "OnRowChanged()" is fired however: Thanks in advance.

private static void Test()
{
DataSet ds1 = new DataSet();
DataTable dt1 = ds1.Tables.Add("MyTable");
DataColumn primaryKeyColumn = dt1.Columns.Add("Key", typeof(int));
dt1.PrimaryKey = new DataColumn[] { primaryKeyColumn };
dt1.Columns.Add("Name", typeof(string));
DataRow dr1 = dt1.Rows.Add(1, "John");
ds1.AcceptChanges();

DataSet ds2 = ds1.Copy();
ds2.Tables["MyTable"].Rows[0]["Name"] = "David";

dt1.RowChanged += OnRowChanged;
dt1.ColumnChanged += OnColumnChanged;
ds1.Merge(ds2);
}

private static void OnRowChanged(object sender, DataRowChangeEventArgs e)
{
}

private static void OnColumnChanged(object sender, DataColumnChangeEventArgs
e)
{
}
May 21 '07 #1
6 2554
Not sure, but it looks to me like you added the event delegate wireup after
you added the new column. Shouldn't it be defined before?
Peter
--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net


"Mark Chambers" wrote:
Hi there,

Does anyone know why the "ColumnChanged" event isn't fired when "Merge()" is
called below. "OnRowChanged()" is fired however: Thanks in advance.

private static void Test()
{
DataSet ds1 = new DataSet();
DataTable dt1 = ds1.Tables.Add("MyTable");
DataColumn primaryKeyColumn = dt1.Columns.Add("Key", typeof(int));
dt1.PrimaryKey = new DataColumn[] { primaryKeyColumn };
dt1.Columns.Add("Name", typeof(string));
DataRow dr1 = dt1.Rows.Add(1, "John");
ds1.AcceptChanges();

DataSet ds2 = ds1.Copy();
ds2.Tables["MyTable"].Rows[0]["Name"] = "David";

dt1.RowChanged += OnRowChanged;
dt1.ColumnChanged += OnColumnChanged;
ds1.Merge(ds2);
}

private static void OnRowChanged(object sender, DataRowChangeEventArgs e)
{
}

private static void OnColumnChanged(object sender, DataColumnChangeEventArgs
e)
{
}
May 21 '07 #2
Not sure, but it looks to me like you added the event delegate wireup
after
you added the new column. Shouldn't it be defined before?
Thanks for the feedback but I'm not sure I follow you. Are you saying I
should assign the event before adding the column? I tried it just to be on
the safe side and the results are the same. I don't see why it should make
any difference however. You can normally hook/unhook an event anytime AFAIK
and I would have been surprised if it did work. It look like something's
just broken on MSFT's side but I'm still hoping to be proved wrong (and
would be happy to take the blame if someone can show me what I am doing
wrong).
May 22 '07 #3
I don't know, I only looked at your code sample briefly. Are you sure the
ColumnChanged event is actually supposed to be fired when you call Merge?

-- Peter
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net


"Mark Chambers" wrote:
Not sure, but it looks to me like you added the event delegate wireup
after
you added the new column. Shouldn't it be defined before?

Thanks for the feedback but I'm not sure I follow you. Are you saying I
should assign the event before adding the column? I tried it just to be on
the safe side and the results are the same. I don't see why it should make
any difference however. You can normally hook/unhook an event anytime AFAIK
and I would have been surprised if it did work. It look like something's
just broken on MSFT's side but I'm still hoping to be proved wrong (and
would be happy to take the blame if someone can show me what I am doing
wrong).
May 22 '07 #4
>I don't know, I only looked at your code sample briefly. Are you sure the
ColumnChanged event is actually supposed to be fired when you call Merge?
Unfortunately, the docs aren't entirely clear but AFAICT it should be. If
you change a field's value in a "DataTable" record it's supposed to fire to
indicate which field (column) has changed. It works if you change the value
directly in the record itself which is how most will usually rely on it. It
doesn't work when you merge your changes however but it should in theory.
The "RowChanged" event works that is (as previously noted) so
"ColumnChanged" should work as well. You would expect it to.
May 22 '07 #5
Unfortunately, the docs aren't entirely clear but AFAICT it should be. If
you change a field's value in a "DataTable" record it's supposed to fire
to indicate which field (column) has changed. It works if you change the
value directly in the record itself which is how most will usually rely on
it. It doesn't work when you merge your changes however but it should in
theory. The "RowChanged" event works that is (as previously noted) so
"ColumnChanged" should work as well. You would expect it to.
Ok, MSFT has now confirmed this is a bug and has submitted it for repair.
Thanks for your help.
May 23 '07 #6
Bully for you, if you found a legitimate bug. 99 out of 100 are simply user
stupidity, not bugs at all. Congratulations!
Peter
--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net


"Mark Chambers" wrote:
Unfortunately, the docs aren't entirely clear but AFAICT it should be. If
you change a field's value in a "DataTable" record it's supposed to fire
to indicate which field (column) has changed. It works if you change the
value directly in the record itself which is how most will usually rely on
it. It doesn't work when you merge your changes however but it should in
theory. The "RowChanged" event works that is (as previously noted) so
"ColumnChanged" should work as well. You would expect it to.

Ok, MSFT has now confirmed this is a bug and has submitted it for repair.
Thanks for your help.
May 24 '07 #7

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

Similar topics

2
by: Pete | last post by:
I have some funky form/event behavior. Access 97. Split frontend/backend, using Access security. I have the same behavior (or lack of behavior) for the pag_Click() event of two separate pages...
13
by: Manuel Lopez | last post by:
I have a puzzling form timer problem that I didn't experience prior to Access 2003 (though I'm not sure access 2003 is to blame). Here's the situation: a computer has two access 2003 databases on...
0
by: Ram | last post by:
I have a start page for my application default.htm which contains four frames. header.htm login.aspx rightside.htm footer.htm login.aspx conatins username, password fields and login button....
3
by: Brett | last post by:
I'm using a third part component in a certain app. The component has methods and events. I noticed one particular event was not firing after a while but it should have been. The problem was the...
1
by: Diana | last post by:
I've got a database that has been working successfully for a number of years now. I just added a new item - basically a field that becomes visible depending on another field's value. When I was...
4
by: TS | last post by:
I am creating a User control and i create some dynamic controls in the init handler. one of the controls is a custom validator which i assign a serverValidate event handler. I usally always do my...
5
by: jaysonnward | last post by:
Hello All: I've recently been recreating some 'dropdown menus' for a website I manage. I'm writing all my event handlers into my .js file. I've got the coding to work in Firefox, but the...
6
by: sjoshi | last post by:
I have a derived class OraBackup which has a method that calls stored procedure on Oracledb to get status of backup job. Now the base class publishes an event like this: public delegate void...
2
by: John Kotuby | last post by:
Hi guys, I am converting a rather complicated database driven Web application from classic ASP to ASP.NET 2.0 using VB 2005 as the programming language. The original ASP application works quite...
1
by: bigijoseph | last post by:
Please help : page load event is not firing. -------------------------------------------------------------------------------- Hi, I am a new to .net. I am trying to learn it. I tried the...
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
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:
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
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
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
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.