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,019 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VB .NET application would like equitable cpu usage 3 25
how to read json value 2 27
SQL Login 17 37
I need help making a collection from a class in VB.Net 3 21
Update (December 2011): Since this article was published, the things have changed for good for Android native developers. The Sequoyah Project (http://www.eclipse.org/sequoyah/) automates most of the tasks discussed in this article. You can even fin…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

939 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

11 Experts available now in Live!

Get 1:1 Help Now