DataSet DataType

  • Thread starter Thread starter Meelis Lilbok
  • Start date Start date
M

Meelis Lilbok

Hi

Still cant resolve problem, how to get datatype and properties for field.

If if fill DataSet from SQL Database how can i

a) Get DataType for specified field
b) Get Allow null (if i read AllowDBNull this returns always True)



Regards;
Meelis
 
Meelis Lilbok said:
Hi

Still cant resolve problem, how to get datatype and properties for
field.

If if fill DataSet from SQL Database how can i

a) Get DataType for specified field

The DataColumn's DataType property returns the data type.

The field value (Integer, String, whatever) has a GetType method returning
the value's data type. In VB.Net you can also use "If TypeOf FieldValue Is
...."
b) Get Allow null (if i read AllowDBNull this returns always True)

No, don't /read/ it, /set/ it. If you don't set it, it's True by default.
The property determines whether the field can be null in the datatable, not
whether it can be null in the database. You should set the property
according to the field definition in the database.

To find out whether Null is allowed, read the table schema by using the
GetOleDbSchemaTable method of the OleDbConnection.


Armin
 
Back
Top