如何在数据更改时自动更新UI [英] How to Automatically Update UI When Data Changes

查看:88
本文介绍了如何在数据更改时自动更新UI的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这里应该有一个副标题我确定我之前曾经问过这个

,但是......


两个用户都在从数据库中查看相同的数据。一个用户

更改数据并提交。如果不轮询更改,其他用户如何获得更新的

视图?是否有某种回调机制

可以在数据集或连接上设置?


TIA


Charles

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

推荐答案

嗨Charles,


我不确定回调机制,我认为Oracle有一些东西

,但你可以提供一个刷新按钮和一种机制,当第二个用户试图改变数据时,他被告知数据是

自从数据库中检索后发生了变化。这可以使用

时间戳字段来完成,该字段与数据一起被检索。当你进行

更新时,首先得到时间戳,看它是否相同;如果没有,

其他人更改了数据,你可以给用户一个窗口,看看

的变化。


- -


祝你好运,

Carlos J. Quintero


MZ-Tools:生产力添加-ins for Visual Studio

您可以更快地编码,设计和记录:
http://www.mztools.com

" Charles Law" < BL *** @ nowhere.com> escribióenel mensaje

news:uY ************** @ TK2MSFTNGP05.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**************@TK2MSFTNGP05.phx.gbl...
这里是'一个应该有副标题的我确定我之前曾问过这个,但是......。

两个用户都在查看相同的数据,来自数据库。一个用户
更改数据并提交。如果不轮询更改,其他用户如何获得更新的
视图?是否有某种回调机制可以在数据集或连接上设置?

TIA

Charles
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



Charles,


如果您使用任何类型的dataadapter / tableadapter和dataset / datatable

比很容易安静。


只要你没有做数据集跟踪已更改的行

acceptchanges。


在更新过程中,代码首先逐行检查数据库中的原始

行。 (创建新的,删除的或更新的)。


如果这是事实而不是你得到并发错误。

请注意接受的行被处理,所以恢复过程不简单。

(虽然你可以设置与begintransaction和提交的连接或

非提交) 。


由于大多数情况下这种情况很少发生,因此它被称为乐观并发。

但是你必须检查并创建程序。

即使这是告诉设置所有东西回到第一个州并且

告诉用户再次完成他的工作。


很简单,不是吗?


Cor


" Charles Law" < BL *** @ nowhere.com> schreef in bericht

新闻:uY ************** @ TK2MSFTNGP05.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 begintransaction 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**************@TK2MSFTNGP05.phx.gbl...
这里有一个应该有一个小标题我确定我曾经问过这个,但是......。

两个用户都在查看相同的数据,来自数据库。一个用户
更改数据并提交。如果不轮询更改,其他用户如何获得更新的
视图?是否有某种回调机制可以在数据集或连接上设置?

TIA

Charles
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



嗨卡洛斯


感谢您的回复。我更多地考虑了一种自动方式,以便第二个用户在发生变化时收到通知,而不是当他试图做出改变的时候和/ b
。在我看来,这似乎是非常广泛需要的东西。我现在回忆起我之前问过这个问题,但我现在正在寻找一个WinForms应用程序,所以也许

有办法吗?


Charles

" Carlos J. Quintero [VB MVP]" < CA ***** @ NOSPAMsogecable.com>在留言中写道

news:e1 ************* @ TK2MSFTNGP02.phx.gbl ...
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*****@NOSPAMsogecable.com> wrote in message
news:e1*************@TK2MSFTNGP02.phx.gbl...
嗨Charles,
我不确定回调机制,我认为Oracle有一些东西,但你可以提供一个刷新按钮和一个机制,当第二个用户试图改变数据时,他被告知数据自从数据库中检索后发生了变化。这可以使用
时间戳字段来完成,该字段与数据一起被检索。当你进行
更新时,首先会得到时间戳,看它是否相同;如果没有,
其他人更改了数据,您可以为用户提供一个窗口来查看更改。

-

最好的问候,

Carlos J. Quintero

MZ-Tools:Visual Studio的生产力插件
您可以更快地编码,设计和记录:
< a rel =nofollowhref =http://www.mztools.comtarget =_ blank> http://www.mztools.com

Charles Law ; < BL *** @ nowhere.com> escribiónelel mensaje
新闻:uY ************** @ TK2MSFTNGP05.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**************@TK2MSFTNGP05.phx.gbl...
这里应该是有一个子标题我确定我曾经问过这个,但是......。

两个用户都在从数据库中查看相同的数据。一个用户
更改数据并提交。如果不轮询更改,其他用户如何获得更新的
视图?是否有可以在数据集或连接上设置的某种回调机制?

TIA

Charles
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




这篇关于如何在数据更改时自动更新UI的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆