如何在 C# 中同步/检查从数据库到数据表的数据? [英] How to synchronise/check the data from database to datatable in C#?

查看:24
本文介绍了如何在 C# 中同步/检查从数据库到数据表的数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 DataGridView 使用 DataTable 作为我的数据源.现在我的问题是如何使我的数据表与我们的服务器数据库保持同步?例如,有人试图更新数据库,因此我的数据表也会自动更新.不使用迭代.这可能吗?

I have a DataGridView using DataTable as my datasource. Now my problem is how do I keep my datatable synchronised to our server database? Like for example somebody tried to update the database so automatically my datatable will be updated too. Without using iteration. Is this possible?

推荐答案

软件中没有自动.我们需要将看似自动的事情自动化.您可以为您的解决方案使用缓存机制.可以使用缓存填充数据表.更改数据库中的基础表时可以使缓存无效.并且在失效时,必须重新创建数据表,因此必须更新网格视图.

There is nothing automatic in software. We need to automate things that seems to be automatic. You can use caching mechanism for your solution. The datatable can be filled using a cache. The cache can be made invalid on change of underlying tables in the database. And upon invalidating, the datatable shall have to be recreated again and so the gridview shall have to be updated.

如果您使用的是 ASP.NET,您可以在此处参考 MSDN 文章:http://msdn.microsoft.com/en-us/library/ms972379.aspx

If you are using ASP.NET, you can refer the MSDN article on the same here: http://msdn.microsoft.com/en-us/library/ms972379.aspx

这篇关于如何在 C# 中同步/检查从数据库到数据表的数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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