BTW, I remember I was trying to answer the same question.
Take a look at this answer at StackOverflow, I think I also used it in our code.
http://stackoverflow.com/questions/459572/how-do-i-get-the-sqldbtype-of-a-column-in-a-table-using-ado-net>>There is SqlDbType.VarChar data type, but System.String type. So, for all char data it will be System.String type.
>
>Well, this causes a problem, as when I use a database which is not bound to my data dictionary, I need to rely on what the DataTable will return. So, I need to be able to differentiate between a string and a varchar.
>
>For example, this is a method I have that I call when I need to know the data type of a column, if I do not have my data dictionary to rely on. This assumes oDataTable is already available. So, I pass the field, in this case a column formely known in SQL Server, and the property I need to get info from. So, the one that is of interest here is DataType. So, I can call the method here with "FirstName", "DataType" and this will return System.String, for example, if FirstName is a column of type Character in SQL Server. But, I need a way to differentiate that from a VarChar. This seems impossible I would assume.
>
>
> ' Return a property of a field
> ' expC1 Field
> Public Function GetColumnProperty(ByVal tcField As String, ByVal tcProperty As String) As Object
> Dim lcFieldName As String = ""
> Dim loRow As DataRow = Nothing
>
> ' Trim just in case
> tcField = Trim(tcField)
>
> ' Locate the field
> For Each loRow In oDataTable.Rows
> lcFieldName = loRow("ColumnName")
>
> ' If this is the field
> If UCase(lcFieldName) = UCase(tcField) Then
>
> ' This is an example to get the type for the column
> lcType = loRow("DataType")
>
> End If
>
> Next
>
If it's not broken, fix it until it is.
My Blog