DataSet DataType

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
 
A

Armin Zingler

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top