• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1034
  • Last Modified:

Using vb.net 2005, how do I determine the datatype of a column in a typed dataset?

I'm trying to assign values to columns in a dataset, but need to know what the datatype of the column is before I do, so I don't assign in invalid value.

Any ideas?


0
genehayes
Asked:
genehayes
1 Solution
 
PaulHewsCommented:
You can determine a datatype at runtime with code like this:

For Each col As DataColumn In MyDatatable.Columns
    If col.DataType Is GetType(String) Then
        MsgBox(col.ColumnName & " is a string")
    End If
    If col.DataType Is GetType(Integer) Then
        MsgBox(col.ColumnName & " is an integer")
    End If

Next
0
 
genehayesAuthor Commented:
Excellent!  I was working around it, but never quite got there.  Thanks!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now