如何从数据表中检索数据类型SIZE [英] How to retrieve the datatype SIZE from the datatable

查看:75
本文介绍了如何从数据表中检索数据类型SIZE的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何从数据表中检索列数据类型大小。



提前感谢:)



我尝试过:



 Dim tblProducts as DataTable 




对于i As Integer = 0到tblProducts.Rows.Count
Dim d = tblProducts.Columns(i).DataType'hele如何检索数据类型大小? :(
下一步

解决方案

您的意思是'尺寸'列的数据类型吗?

 tblProducts.Columns [  size]。DataType 



另外!列是列的集合(令人惊讶)并且与行数无关!!!

如果你想迭代列,请使用如下循环:

 对于 每个 tblProducts.Columns 
' 您的代码
下一页

要检索字符串列的大小,请使用 MaxLength [ ^ ]属性:

  Dim  s 作为 整数 = tblProducts.Columns (ⅰ).MaxLength 


how to retrieve the column datatype size form the data table.

thanks in advance :)

What I have tried:

Dim tblProducts as DataTable
.
.
.

For i As Integer = 0 To tblProducts.Rows.Count
                     Dim d = tblProducts.Columns(i).DataType ' here How to retrieve the datatype size ?? :(
        Next

解决方案

Do you mean the data type for column 'size'?

tblProducts.Columns["size"].DataType


Also! Columns is a collection of the columns (surprisingly) and has nothing to do with the number of rows!!!
If you want to iterate over the columns use a loop like this:

For Each column In tblProducts.Columns
  ' Your code here
Next


To retrieve the size of a string column, use the MaxLength[^] property:

Dim s As Integer = tblProducts.Columns(i).MaxLength


这篇关于如何从数据表中检索数据类型SIZE的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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