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,018 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
Comment Utility
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
Comment Utility
Excellent!  I was working around it, but never quite got there.  Thanks!
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.

763 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

10 Experts available now in Live!

Get 1:1 Help Now