Data Type

  • Thread starter Thread starter Peter
  • Start date Start date
P

Peter

How do I get what datatype a database field is (not what kind of data it
contains)
For example in Access database if I have a DateTime field and it contains
Null if I use the following code I get "System.DbNull"

dataRow[cl.ColumnName].GetType().ToString()

What I need is the info on what type of datafield is it? I need a method
that will return "System.DateTime"

Peter
 
Thank you

That was what I wanted!


Miha Markic said:
Hi Peter,

table.Columns[cl.ColumnName].DataType should do.

--
Miha Markic [MVP C#] - RightHand .NET consulting & software development
miha at rthand com
www.rthand.com

Peter said:
How do I get what datatype a database field is (not what kind of data it
contains)
For example in Access database if I have a DateTime field and it contains
Null if I use the following code I get "System.DbNull"

dataRow[cl.ColumnName].GetType().ToString()

What I need is the info on what type of datafield is it? I need a method
that will return "System.DateTime"

Peter
 
Back
Top