当向数据库表中添加更多列时,如何让 datagridview 显示更改?

when adding a column more to a DB table, how do you get your datagridview to show the change?(当向数据库表中添加更多列时,如何让 datagridview 显示更改?)

本文介绍了当向数据库表中添加更多列时,如何让 datagridview 显示更改?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Visual Studio 的一个项目中创建了一个数据集,它指向我数据库中的一个表然后绑定一个datagridview控件.

I have created a dataset in a project in visual studio that points to a table in my database and then bound a datagridview control to it.

现在我打开数据库并向数据库中的表添加另一列.然后我打开数据集并更新其配置以包含更改.

Now I open the database and add another column to the table in the database. Then i open the dataset and update it's configuration to include the change.

然后我想更新datagridview,但我无法添加新列.我可以在datagridview所在的表格中右键单击tableadapter,并获取正确的表格数据.

Then i want to update the datagridview, but I can't add the new column. I can right click on the tableadapter in the form where the datagridview is and get the correct table data up.

如果我从表单中删除 tableadapter 和 bindingsource 和 dataset 实例,然后尝试重新绑定它,datagridview 仍然不允许我添加新列.

It does not matter if I delete the tableadapter and the bindingsource and dataset instance from the form, and then try and rebind it, the datagridview still won't let me add the new column.

有人知道发生了什么吗?
我已经尝试过几个项目,包括 VS2008 和 2010 beta,而不是 C# 以外的其他语言.
到目前为止,唯一的解决方案似乎是制作一个完全不同的数据集,但必须有更好的方法.

Does anyone have an idea what is happening?
I've tried this with several projects, both VS2008 and 2010 beta, not with other languages than C# tho.
The only solution so far seems to be to make a whole different dataset, but there has to be a better way.

提前致谢

推荐答案

在文件夹下
"C:UsersYOURUSERNAMEAppDataLocalMicrosoftVisualStudio9.0ProjectAssemblies"
Visual Studio 有大量编译过的东西用于快速参考.这些以某种散列方案命名,因此我们无法分辨哪一个是我们拙劣的表方案的编译设置.
1. 我们首先关闭 Visual Studio(我只是为了安全起见)
2. 删除 ProjectAssemblies 文件夹中的所有文件夹.
3.再次打开Visual Studio
4. 重建解决方案
5. 现在,当我们向 datagridview 添加列时,我们得到了正确的值.

Under the folder in
"C:UsersYOURUSERNAMEAppDataLocalMicrosoftVisualStudio9.0ProjectAssemblies"
visual studio has a load of compiled things it uses for quick reference. These are named after some hashing scheme so we can't tell which one is the compiled settings for our botched table scheme.
1. We start by closing Visual Studio (I just did it to be on the safe side)
2. Delete all the folders in the ProjectAssemblies folder.
3. Open up Visual Studio again
4. Rebuild solution
5. And NOW we get the correct values when we add columns to our datagridview.

哇!:D

这篇关于当向数据库表中添加更多列时,如何让 datagridview 显示更改?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:当向数据库表中添加更多列时,如何让 datagridview 显示更改?