如何在我添加的现有数据表中添加新列,但它是bofore行的结尾 [英] how add new column in existing datatable i added but its is come end of the bofore rows

查看:72
本文介绍了如何在我添加的现有数据表中添加新列,但它是bofore行的结尾的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的数据表包含两列;

ID值
----- -------
1100
2150

我想再添加一个这样的列,实际上它位于2和150的末尾
行,但我想从下面的预览开始;

ID值CourseID
----- ------ ----------
1100 1
2 150 1

请帮助我,
pavan

my datatable contans two columns ;

ID Value
----- -------
1 100
2 150

I want to added another column like this ,actually it is come in end of the 2 and 150
row, but I want to start from below preview;

ID Value CourseID
----- ------ ----------
1 100 1
2 150 1

please help me,
pavan

推荐答案

添加列时,根据您的说法,我假设它是在第2、150行之后插入的,例如(3、200).

如果是这样,那么那不是一列-它是一行.您希望将一列添加到数据库的源中,而不是尝试将其添加到表本身中.

可能是您的DataTable已加载或绑定到数据库源,以查看是否在Visual Studio Server资源管理器窗格中或在适当的数据库管理系统-MsSql的Sql Management Studio中添加列.
When you add your column, I assume from what you say that it is being inserted after the 2, 150 row as (for example) 3, 200.

If so, then that is not a column - it is a row. You want to add a column to the source of your database, rather than tryign to add it to the table itself.

Probably, your DataTable is loaded or bound to a Database source, to look at adding a column either in the Visual Studio Server Explorer pane, or in the appropriate database management system - Sql Management Studio for MsSql.


想要在数据表中的特定位置插入一行是没有意义的,因为它对用户不可见,并且您可以将其可视化地放置在控件中您想要用来显示它的任何位置,如下所示我要在其中替换WinForms应用程序中DataGridView中的列.

It makes no sense to want to insert a row in a DataTable at a specific location as it is not visible to the user and you can visually place it anywhere you want in the control that you do use to display it as shown here where I am replacing a column in a DataGridView in a WinForms application.

ToDoManager.Controls.DataGridViewImageButtonSaveColumn col = new ToDoManager.Controls.DataGridViewImageButtonSaveColumn();
            dgvLinks.Columns.Insert(0, col);
            dgvLinks.Columns.RemoveAt(1);



但是如果您必须放置在特定位置,请尝试;



but if you must place at a specific location try;

_masterTable.Columns.Add().SetOrdinal(index)


这篇关于如何在我添加的现有数据表中添加新列,但它是bofore行的结尾的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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