使用最新的列信息更新 DataColumn
我有一个包含许多数据列的数据集,由于大小问题,我已将许多 varchar 列从 VARCHAR(20) 更新为 VARCHAR(50)。
我希望 DataTable 自动获取新列信息,这可能吗?我不想遍历表中的每一列并更新长度。
I have a dataset with a number of data columns, due to sizing issues I've updated a number of the varchar columns from say VARCHAR(20) to VARCHAR(50).
I'd like the DataTable to automatically grab the new column information, is this possible? I'd rather not go through each column in the table and update the length.
在设计器中删除并重新创建数据表没有完成任务?我很好奇。
好吧,很久以前(5 年?)我编写了一个小程序,它能够读取 SQL Server 数据库架构并为我创建该数据集。抱歉 - 我不再有该代码了。
“您所要做的就是读取数据库架构(对于 SQL Server 来说是表 sysobjects 和 syscolumns)并通过实例化 DataTable 和 DataColumn 对象来创建数据集。
也许对你来说不是最好的选择,但对我来说这是一个很好的选择。
(备注:不,我正在使用 OR Mapper - 不再有数据集)
Deleting and recreating the DataTable in the designer did not the job? I'm wondering.
Well, long time ago (5 years?) I made a small program which was able to read a SQL Server Database Schema and create that DataSet for me. Sorry - I do not have that code any more.
"All you have to do" is to read the database schema (for SQL Server the Table sysobjects and syscolumns) and create the Dataset by instantiating DataTable and DataColumn objects.
Maybe not the best option for you, but in my case it was a great option.
(Remark: No I'm using OR Mapper - no Datasets anymore)