How to get DataType of a column

Posted on 2008-11-09
Last Modified: 2013-12-17
How can i get a column data type like varchar, char, smallint

DataColumn.DataType.Name returns string for varchar, nvarchar. I want exact data type. How can i get it.
Question by:ynaina
    1 Comment
    LVL 20

    Accepted Solution

    'For example, declare a column of type Integer:

    Dim dc As New DataColumn
    dc.DataType = GetType(Integer)

    'Get it's type:

    Dim t As Type = dc.DataType

    'Then, do something with it:

    Dim s As String
     If t Is GetType(Integer) Then
           s = "I'm an Integer"
           s = "I'm something else"
    End If

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Better Security Awareness With Threat Intelligence

    See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

    It’s quite interesting for me as I worked with Excel using for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
    Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
    Need more eyes on your posted question? Go ahead and follow the quick steps in this video to learn how to Request Attention to your question. *Log into your Experts Exchange account *Find the question you want to Request Attention for *Go to the e…
    Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

    761 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    6 Experts available now in Live!

    Get 1:1 Help Now