无法正确显示更新的数据. [解决了] [英] Having trouble with updated data displaying correctly. [Solved]

查看:58
本文介绍了无法正确显示更新的数据. [解决了]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,

我在获取表单以显示最近更新的数据时遇到了一些麻烦.奇怪的是,这仅发生在十进制,整数或仅与数字有关的其他字段上.

在用户进行了所需的任何更改之后,将新数据保存到数据库中后,它将更新到数据库,但是表格仍将显示旧数据,直到应用程序完全关闭,然后重新执行操作.开始.我知道数据库将按照应有的方式进行更新,但是应用程序不会显示新的更改,而且正如我已经提到的那样,这仅在数字字段中发生.只要不是数字数据类型,应用程序中的所有其他数据都将准确显示应如何显示.

我注意到的一件事是,与仅使用.showdialog输入表单名称相比,如果将其声明为新表单然后将其打开,则表单将显示正确的数据.唯一的问题是,由于我项目中某些表单的性质,将它们声明为新表单会与我已有的大量代码冲突.

我的问题是,可能是什么原因导致这种情况的发生,我需要怎么做才能解决该问题?

另外,我的代码是用Visual Basic编写的,并且我使用LINQ to Entities来检索,更新和删除记录.该数据库存储在SQL Server 2008 R2中.

感谢您的所有帮助.

Hello,

I''m having some trouble with getting my forms to display the recently updated data. The weird thing is that this only happens on decimal, int, or other fields having to do with only numbers.

What happens is after the user makes whatever changes they need to make and then saves the new data it''ll update it to the database, but the forms will still display the old data, until the application is completely shut down and then re-started. I know the database is being updated exactly like it should be, but the application just won''t show the new changes and as I''ve already mentioned, this only happens with numeric fields. All other data in the application will be shown exactly how it should as long as its not a numeric data type.

One thing I have noticed is that the forms will show the correct data, if I declare it as a new form and then open it compared to just typing in the name of the form with .showdialog. The only problem with this is that, due to the nature of some of the forms in my project, declaring them as a new form would conflict with a nice amount of my code that is already in place.

My question is, what could possibly be causing something like this and what do I need to do to fix it?

Also, my code is written in Visual Basic, and I use LINQ to Entities for retrieving, updating, and deleting records. The database is stored in SQL Server 2008 R2.

Thanks for any and all help.

推荐答案

无论何时填充表单,都应为给定实体创建一个新的存储库上下文,以便更新数据.如果您具有静态上下文,那么如果将更改保存在另一个上下文中,则可能看不到更改.
Whenever you are populating your forms, you should create a new repository context for the given entities so that the data is updated. If you have a static context you may not be seeing the changes if they are saved under another context.


这篇关于无法正确显示更新的数据. [解决了]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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