|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
How to know length (data width) of column from VB.NetHi,
I have a table in SQL Server 2000 and accessing it in ADO.Net , I want to know fields width and I gave following VB.Net commands but I am fail to know it, it returns -1 for all columns. Dim col as data.datacolumn For Each col in ds.tables(0).columns ' ds is a dataset Console.Writeline (col.maxlength) Next Thanks in advance. Hardik Shah. Hi there,
1. (preffered) Use sp_columns stored procedure to obtain full complete column description 2. MaxLen works fine for text/binary columns, for other (value) types you have to use DataType and System.Runtime.InteropServices.Marshal.SizeOf but you will get .net underlying type information Hope this helps -- Show quoteMilosz Skalecki MCP, MCAD "Hardik Shah" wrote: > Hi, > > I have a table in SQL Server 2000 and accessing it in ADO.Net , I want to > know fields width and I gave following VB.Net commands but I am fail to know > it, it returns -1 for all columns. > > Dim col as data.datacolumn > > For Each col in ds.tables(0).columns ' ds is a dataset > Console.Writeline (col.maxlength) > Next > > Thanks in advance. > > Hardik Shah. > > > > > |
|||||||||||||||||||||||