Home All Groups Group Topic Archive Search About
Author
21 Mar 2006 12:13 PM
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

Author
21 Mar 2006 12:27 PM
Armin Zingler
"Meelis Lilbok" <meelis.lil***@deltmar.ee> schrieb
> 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