Mr_Shaw
asked on
.MaxLength.ToString();
when I write
row["Data_Length"] = col.MaxLength.ToString();
it return I get a value of -1.
what does -1 indicate?
row["Data_Length"] = col.MaxLength.ToString();
it return I get a value of -1.
what does -1 indicate?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
How can I get the length of the data type in a column?
The length of the column or the length of the data in the current row?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
How do I find out the lenght of the data type in the columns?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You can determine a datatype at runtime using the following code:
For Each col As DataColumn In MyDatatable.Columns
If col.DataType Is GetType(String) Then
MsgBox(col.ColumnName & " is a string")
End If
If col.DataType Is GetType(Integer) Then
MsgBox(col.ColumnName & " is an integer")
End If
' etc...
Next
ASKER
Medo3337... how about getting the length?
eg. the string length
eg. the string length
Here is SQL to get the field length:
SELECT
sysobjects.name AS "TABLE_NAME",
syscolumns.name AS "COLUMN_NAME",
systypes.name AS "DATA_TYPE",
syscolumns.LENGTH AS "LENGTH"
FROM
sysobjects
INNER JOIN
syscolumns ON sysobjects.id = syscolumns.id
INNER JOIN
systypes ON syscolumns.xtype = systypes.xtype
WHERE
(sysobjects.xtype = 'U') andsysobjects.name = 'MyTableName'
ORDER BY sysobjects.name, syscolumns.colid
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thanks
ASKER
row["Data_Length"] = col.MaxLength.ToString();