473,769 Members | 2,143 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to Automatically Update UI When Data Changes

Here's one that should probably have the sub-heading "I'm sure I asked this
once before, but ...".

Two users are both looking at the same data, from a database. One user
changes the data and commits it. How does the other user get the updated
view without polling for changes? Is there some sort of callback mechanism
that can be set up on the dataset or connection?

TIA

Charles
Jun 7 '06 #1
32 2005
Hi Charles,

I am not sure about callback mechanisms, I think that Oracle had something
of that, but you can provide a Refresh button and a mechanism that when the
second user tries to change the data, he is notified that the data was
changed since it was retrieved from the database. This can be done using a
timestamp field which is retrieved along with the data. When you do the
update, you get the timestamp first to see if it is the same; if not,
someone else changed the data and you can offer the user a window to see the
changes.

--

Best regards,

Carlos J. Quintero

MZ-Tools: Productivity add-ins for Visual Studio
You can code, design and document much faster:
http://www.mztools.com
"Charles Law" <bl***@nowhere. com> escribió en el mensaje
news:uY******** ******@TK2MSFTN GP05.phx.gbl...
Here's one that should probably have the sub-heading "I'm sure I asked
this once before, but ...".

Two users are both looking at the same data, from a database. One user
changes the data and commits it. How does the other user get the updated
view without polling for changes? Is there some sort of callback mechanism
that can be set up on the dataset or connection?

TIA

Charles

Jun 7 '06 #2
Charles,

If you are using any kind of dataadapter/tableadapter and dataset/datatable
than it is quiet easy.

A dataset keeps track of the changed rows as long as you did not do
acceptchanges.

In the update process the code checks first row by row of those original
rows are changed in the database. (Created new, deleted or updated).

If that is the fact than you get a concurrency error.
Be aware that accepted rows are handled, so the recovery process is not
easy.
(Although you can set the connection with a begintransactio n and a commit or
non commit of that).

Because of the fact that this situations in most situations is seldom, it is
called optimistic concurrency.
However you have to check it and creates the procedures.
Even if that is telling setting everything back to the first state and
telling the user to do his job again.

Very simple is it not?

Cor

"Charles Law" <bl***@nowhere. com> schreef in bericht
news:uY******** ******@TK2MSFTN GP05.phx.gbl...
Here's one that should probably have the sub-heading "I'm sure I asked
this once before, but ...".

Two users are both looking at the same data, from a database. One user
changes the data and commits it. How does the other user get the updated
view without polling for changes? Is there some sort of callback mechanism
that can be set up on the dataset or connection?

TIA

Charles

Jun 7 '06 #3
Hi Carlos

Thanks for the reply. I was thinking more of an automatic way, so that the
second user is notified of the change when it happens, rather than if and
when he tries to make a change. This seems to me like something that would
be quite widely desired. I recollect now that I asked this before wrt web
applications, but I am now looking at a WinForms application, so perhaps
there is a way?

Charles
"Carlos J. Quintero [VB MVP]" <ca*****@NOSPAM sogecable.com> wrote in message
news:e1******** *****@TK2MSFTNG P02.phx.gbl...
Hi Charles,

I am not sure about callback mechanisms, I think that Oracle had something
of that, but you can provide a Refresh button and a mechanism that when
the second user tries to change the data, he is notified that the data was
changed since it was retrieved from the database. This can be done using a
timestamp field which is retrieved along with the data. When you do the
update, you get the timestamp first to see if it is the same; if not,
someone else changed the data and you can offer the user a window to see
the changes.

--

Best regards,

Carlos J. Quintero

MZ-Tools: Productivity add-ins for Visual Studio
You can code, design and document much faster:
http://www.mztools.com
"Charles Law" <bl***@nowhere. com> escribió en el mensaje
news:uY******** ******@TK2MSFTN GP05.phx.gbl...
Here's one that should probably have the sub-heading "I'm sure I asked
this once before, but ...".

Two users are both looking at the same data, from a database. One user
changes the data and commits it. How does the other user get the updated
view without polling for changes? Is there some sort of callback
mechanism that can be set up on the dataset or connection?

TIA

Charles


Jun 7 '06 #4
Hi Cor

Sorry if I am not catching on very quickly, but I don't quite see how your
scenario would work.
A dataset keeps track of the changed rows as long as you did not do
acceptchanges.
Isn't this the dataset of the user who has made the changes? What about the
dataset of the user who is just viewing the data? Does that get some
notification of the changes as well?
In the update process the code checks first row by row of those original
rows are changed in the database. (Created new, deleted or updated).
This sounds like something that would happen when the second user tries to
make changes, in which case I agree that there would be some sort of error
because the data had already changed. But suppose the second user is just
looking at the data? Because datasets are disconnected in .NET it seems to
me that the second user might never see the changes unless he specifically
reloads the data.

Charles
"Cor Ligthert [MVP]" <no************ @planet.nl> wrote in message
news:uu******** ******@TK2MSFTN GP02.phx.gbl... Charles,

If you are using any kind of dataadapter/tableadapter and
dataset/datatable than it is quiet easy.

A dataset keeps track of the changed rows as long as you did not do
acceptchanges.

In the update process the code checks first row by row of those original
rows are changed in the database. (Created new, deleted or updated).

If that is the fact than you get a concurrency error.
Be aware that accepted rows are handled, so the recovery process is not
easy.
(Although you can set the connection with a begintransactio n and a commit
or non commit of that).

Because of the fact that this situations in most situations is seldom, it
is called optimistic concurrency.
However you have to check it and creates the procedures.
Even if that is telling setting everything back to the first state and
telling the user to do his job again.

Very simple is it not?

Cor

"Charles Law" <bl***@nowhere. com> schreef in bericht
news:uY******** ******@TK2MSFTN GP05.phx.gbl...
Here's one that should probably have the sub-heading "I'm sure I asked
this once before, but ...".

Two users are both looking at the same data, from a database. One user
changes the data and commits it. How does the other user get the updated
view without polling for changes? Is there some sort of callback
mechanism that can be set up on the dataset or connection?

TIA

Charles


Jun 7 '06 #5
Charles,

The described process keeps only track for the updating user to prevent that
there will not wrong changed data because there where already changes in the
meantime.

What if the first was looking while the second was on the toilet and did the
updates after that while the other one was already not looking anymore.
Should there be a message that he/she was on the toilet but changed it?

This kind of pseudo accuratesse is in most situations already long time seen
as b*sh*t

However not there where there are automatic updates done for by instance by
a stock exchange.

Ken made this sample for this. Problem for me is that it will not work for
me without a 100% load so maybe can you try it as well. Ken has let this
tested by others and told that they had not that problem.

http://www.vb-tips.com/default.aspx?...c-3503c15fd46e

Beside this it is of course advisable not to make processes that keeps to
long the changes data on the client. However if you are on a place where
there is really not any usable connection possible, than it can be that it
takes longer.

I hope this helps,

Cor
"Charles Law" <bl***@nowhere. com> schreef in bericht
news:u7******** ******@TK2MSFTN GP05.phx.gbl...
Hi Cor

Sorry if I am not catching on very quickly, but I don't quite see how your
scenario would work.
A dataset keeps track of the changed rows as long as you did not do
acceptchanges.


Isn't this the dataset of the user who has made the changes? What about
the dataset of the user who is just viewing the data? Does that get some
notification of the changes as well?
In the update process the code checks first row by row of those original
rows are changed in the database. (Created new, deleted or updated).


This sounds like something that would happen when the second user tries to
make changes, in which case I agree that there would be some sort of error
because the data had already changed. But suppose the second user is just
looking at the data? Because datasets are disconnected in .NET it seems to
me that the second user might never see the changes unless he specifically
reloads the data.

Charles
"Cor Ligthert [MVP]" <no************ @planet.nl> wrote in message
news:uu******** ******@TK2MSFTN GP02.phx.gbl...
Charles,

If you are using any kind of dataadapter/tableadapter and
dataset/datatable than it is quiet easy.

A dataset keeps track of the changed rows as long as you did not do
acceptchanges.

In the update process the code checks first row by row of those original
rows are changed in the database. (Created new, deleted or updated).

If that is the fact than you get a concurrency error.
Be aware that accepted rows are handled, so the recovery process is not
easy.
(Although you can set the connection with a begintransactio n and a commit
or non commit of that).

Because of the fact that this situations in most situations is seldom, it
is called optimistic concurrency.
However you have to check it and creates the procedures.
Even if that is telling setting everything back to the first state and
telling the user to do his job again.

Very simple is it not?

Cor

"Charles Law" <bl***@nowhere. com> schreef in bericht
news:uY******** ******@TK2MSFTN GP05.phx.gbl...
Here's one that should probably have the sub-heading "I'm sure I asked
this once before, but ...".

Two users are both looking at the same data, from a database. One user
changes the data and commits it. How does the other user get the updated
view without polling for changes? Is there some sort of callback
mechanism that can be set up on the dataset or connection?

TIA

Charles



Jun 7 '06 #6
AFAIK this is generally not widely wanted (after all if the other user would
have updated few minutes later, the user that is looking the data would have
not seen this change, so the first question is likely is this that critical
to have instant updates or is it enough to just see what is current when you
request for it comapred with the additional complexity/processing cost ? If
you have a special need, such as plane reservation or something similar you
may want to explain what you are trying to do...).

--
Patrice

"Charles Law" <bl***@nowhere. com> a écrit dans le message de news:
u7************* *@TK2MSFTNGP05. phx.gbl...
Hi Cor

Sorry if I am not catching on very quickly, but I don't quite see how your
scenario would work.
A dataset keeps track of the changed rows as long as you did not do
acceptchanges.


Isn't this the dataset of the user who has made the changes? What about
the dataset of the user who is just viewing the data? Does that get some
notification of the changes as well?
In the update process the code checks first row by row of those original
rows are changed in the database. (Created new, deleted or updated).


This sounds like something that would happen when the second user tries to
make changes, in which case I agree that there would be some sort of error
because the data had already changed. But suppose the second user is just
looking at the data? Because datasets are disconnected in .NET it seems to
me that the second user might never see the changes unless he specifically
reloads the data.

Charles
"Cor Ligthert [MVP]" <no************ @planet.nl> wrote in message
news:uu******** ******@TK2MSFTN GP02.phx.gbl...
Charles,

If you are using any kind of dataadapter/tableadapter and
dataset/datatable than it is quiet easy.

A dataset keeps track of the changed rows as long as you did not do
acceptchanges.

In the update process the code checks first row by row of those original
rows are changed in the database. (Created new, deleted or updated).

If that is the fact than you get a concurrency error.
Be aware that accepted rows are handled, so the recovery process is not
easy.
(Although you can set the connection with a begintransactio n and a commit
or non commit of that).

Because of the fact that this situations in most situations is seldom, it
is called optimistic concurrency.
However you have to check it and creates the procedures.
Even if that is telling setting everything back to the first state and
telling the user to do his job again.

Very simple is it not?

Cor

"Charles Law" <bl***@nowhere. com> schreef in bericht
news:uY******** ******@TK2MSFTN GP05.phx.gbl...
Here's one that should probably have the sub-heading "I'm sure I asked
this once before, but ...".

Two users are both looking at the same data, from a database. One user
changes the data and commits it. How does the other user get the updated
view without polling for changes? Is there some sort of callback
mechanism that can be set up on the dataset or connection?

TIA

Charles



Jun 7 '06 #7
Cor
What if the first was looking while the second was on the toilet and did
the updates after that while the other one was already not looking
anymore. Should there be a message that he/she was on the toilet but
changed it?
On return from the lavatory, the user's screen would be up-to-date, that's
all.
This kind of pseudo accuratesse is in most situations already long time
seen as b*sh*t
By whom? It would seem that Microsoft do not see it that way, as they have
introduced the SqlDependency class in VS2005 to address just this situation.

Anyway, I think I have my answer: it is possible only in VS2005 with
SqlServer. Thanks.

Charles
"Cor Ligthert [MVP]" <no************ @planet.nl> wrote in message
news:Of******** ******@TK2MSFTN GP04.phx.gbl... Charles,

The described process keeps only track for the updating user to prevent
that there will not wrong changed data because there where already changes
in the meantime.

What if the first was looking while the second was on the toilet and did
the updates after that while the other one was already not looking
anymore. Should there be a message that he/she was on the toilet but
changed it?

This kind of pseudo accuratesse is in most situations already long time
seen as b*sh*t

However not there where there are automatic updates done for by instance
by a stock exchange.

Ken made this sample for this. Problem for me is that it will not work for
me without a 100% load so maybe can you try it as well. Ken has let this
tested by others and told that they had not that problem.

http://www.vb-tips.com/default.aspx?...c-3503c15fd46e

Beside this it is of course advisable not to make processes that keeps to
long the changes data on the client. However if you are on a place where
there is really not any usable connection possible, than it can be that it
takes longer.

I hope this helps,

Cor
"Charles Law" <bl***@nowhere. com> schreef in bericht
news:u7******** ******@TK2MSFTN GP05.phx.gbl...
Hi Cor

Sorry if I am not catching on very quickly, but I don't quite see how
your scenario would work.
A dataset keeps track of the changed rows as long as you did not do
acceptchanges.


Isn't this the dataset of the user who has made the changes? What about
the dataset of the user who is just viewing the data? Does that get some
notification of the changes as well?
In the update process the code checks first row by row of those original
rows are changed in the database. (Created new, deleted or updated).


This sounds like something that would happen when the second user tries
to make changes, in which case I agree that there would be some sort of
error because the data had already changed. But suppose the second user
is just looking at the data? Because datasets are disconnected in .NET it
seems to me that the second user might never see the changes unless he
specifically reloads the data.

Charles
"Cor Ligthert [MVP]" <no************ @planet.nl> wrote in message
news:uu******** ******@TK2MSFTN GP02.phx.gbl...
Charles,

If you are using any kind of dataadapter/tableadapter and
dataset/datatable than it is quiet easy.

A dataset keeps track of the changed rows as long as you did not do
acceptchanges.

In the update process the code checks first row by row of those original
rows are changed in the database. (Created new, deleted or updated).

If that is the fact than you get a concurrency error.
Be aware that accepted rows are handled, so the recovery process is not
easy.
(Although you can set the connection with a begintransactio n and a
commit or non commit of that).

Because of the fact that this situations in most situations is seldom,
it is called optimistic concurrency.
However you have to check it and creates the procedures.
Even if that is telling setting everything back to the first state and
telling the user to do his job again.

Very simple is it not?

Cor

"Charles Law" <bl***@nowhere. com> schreef in bericht
news:uY******** ******@TK2MSFTN GP05.phx.gbl...
Here's one that should probably have the sub-heading "I'm sure I asked
this once before, but ...".

Two users are both looking at the same data, from a database. One user
changes the data and commits it. How does the other user get the
updated view without polling for changes? Is there some sort of
callback mechanism that can be set up on the dataset or connection?

TIA

Charles



Jun 7 '06 #8
Charles,
This kind of pseudo accuratesse is in most situations already long time
seen as b*sh*t


By whom? It would seem that Microsoft do not see it that way, as they have
introduced the SqlDependency class in VS2005 to address just this
situation.

I showed you that there are situations where that can be the fact.

However mostly not if it is about humans who are updating.

The same as I did with other words is writen by Patrice by the way.

Cor
Jun 7 '06 #9
Hi Patrice

Thanks for the reply.
... such as plane reservation or something similar ...
That is a good example. Also, a bank call centre. The advisor is referring
to information on-screen whilst discussing details with a caller.
Transactions occur asynchronously, so the account balance could change
whilst the call is in progress. Unless the advisor repeatedly presses an
update button, they would not see the changes.

The stock market prices change by the second, and it is important that
traders have up-to-the-second prices on their screens. Polling is very
inefficient. The observer pattern was made for this scenario but I am
hearing that it can't be implemented on a database. I still think that this
_is_ widely wanted, but that we are largely being told that it can't be
done.

Charles
"Patrice" <sc****@chez.co m> wrote in message
news:%2******** ********@TK2MSF TNGP05.phx.gbl. .. AFAIK this is generally not widely wanted (after all if the other user
would have updated few minutes later, the user that is looking the data
would have not seen this change, so the first question is likely is this
that critical to have instant updates or is it enough to just see what is
current when you request for it comapred with the additional
complexity/processing cost ? If you have a special need, such as plane
reservation or something similar you may want to explain what you are
trying to do...).

--
Patrice

"Charles Law" <bl***@nowhere. com> a écrit dans le message de news:
u7************* *@TK2MSFTNGP05. phx.gbl...
Hi Cor

Sorry if I am not catching on very quickly, but I don't quite see how
your scenario would work.
A dataset keeps track of the changed rows as long as you did not do
acceptchanges.


Isn't this the dataset of the user who has made the changes? What about
the dataset of the user who is just viewing the data? Does that get some
notification of the changes as well?
In the update process the code checks first row by row of those original
rows are changed in the database. (Created new, deleted or updated).


This sounds like something that would happen when the second user tries
to make changes, in which case I agree that there would be some sort of
error because the data had already changed. But suppose the second user
is just looking at the data? Because datasets are disconnected in .NET it
seems to me that the second user might never see the changes unless he
specifically reloads the data.

Charles
"Cor Ligthert [MVP]" <no************ @planet.nl> wrote in message
news:uu******** ******@TK2MSFTN GP02.phx.gbl...
Charles,

If you are using any kind of dataadapter/tableadapter and
dataset/datatable than it is quiet easy.

A dataset keeps track of the changed rows as long as you did not do
acceptchanges.

In the update process the code checks first row by row of those original
rows are changed in the database. (Created new, deleted or updated).

If that is the fact than you get a concurrency error.
Be aware that accepted rows are handled, so the recovery process is not
easy.
(Although you can set the connection with a begintransactio n and a
commit or non commit of that).

Because of the fact that this situations in most situations is seldom,
it is called optimistic concurrency.
However you have to check it and creates the procedures.
Even if that is telling setting everything back to the first state and
telling the user to do his job again.

Very simple is it not?

Cor

"Charles Law" <bl***@nowhere. com> schreef in bericht
news:uY******** ******@TK2MSFTN GP05.phx.gbl...
Here's one that should probably have the sub-heading "I'm sure I asked
this once before, but ...".

Two users are both looking at the same data, from a database. One user
changes the data and commits it. How does the other user get the
updated view without polling for changes? Is there some sort of
callback mechanism that can be set up on the dataset or connection?

TIA

Charles



Jun 7 '06 #10

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

Similar topics

3
12552
by: Christopher Koh | last post by:
how do you stop Access from saving any changed data in your tables and queries? like i just add or change data on the table/query tables,then click on X (exit)because i have no intention of saving it but access still automatically saves it even if I did not press the save command on the menu/toolbar? What is the solution for this? help thanks!
30
3404
by: Charles Law | last post by:
Here's one that should probably have the sub-heading "I'm sure I asked this once before, but ...". Two users are both looking at the same data, from a database. One user changes the data and commits it. How does the other user get the updated view without polling for changes? Is there some sort of callback mechanism that can be set up on the dataset or connection? TIA
0
9583
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9423
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,...
0
10210
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10039
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 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...
1
9990
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9860
tracyyun
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...
0
5297
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3955
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
2
3560
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.