如何取到DataTable各个列的最大长度?

yibuyi 2003-08-21 02:03:57
为什么用col.MaxLength会得到-1?
...全文
285 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
dahuzizyd 2003-08-21
  • 打赏
  • 举报
回复
DataColumns.MaxLength:列的最大长度(以字符数表示)。如果列没有最大长度,该值为 -1(默认值)。对于非文本列,则忽略 MaxLength 属性。
TheAres 2003-08-21
  • 打赏
  • 举报
回复
You can use the INFORMATION_SCHEMA views in SQL Server, through a regular
Command, if your database is SQL Server. Or use
OleDbConnection.GetOleDbSchemaTable with an OLE DB provider that supports
it.

Or you can do a DataAdapter.Fill with a MissingSchemaAction of
MissingSchemaAction.AddWithKey. Then refer to DataColumn.MaxLength. Or use
CommandBehavior.KeyInfo or SchemaOnly and look at the DataReader's SchemaTable.

110,536

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧