Solved

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

Posted on 2007-11-30
2
1,020 Views
Last Modified: 2013-11-06
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
Comment
Question by:genehayes
2 Comments
 
LVL 38

Accepted Solution

by:
PaulHews earned 250 total points
ID: 20385647
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
 

Author Closing Comment

by:genehayes
ID: 31412041
Excellent!  I was working around it, but never quite got there.  Thanks!
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How do you do a one to many list in .NET CORE? 2 28
help with regular expression to search string 6 27
Sending receiving text messages in vb.net 15 38
location of a form 2 14
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.

803 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