Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > VB How-To
|
VB How-To Ask your "How do I do this with VB?" questions in this forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 20th, 2004, 08:05 AM
Authorized User
 
Join Date: Aug 2004
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default Determining data type from Excel

Running into some problems with putting data from Excel into a datagrid. When the data is mixed the casting of empty cells to string does not work since doubles are in the data. Also NULL values exist and dealing with them is also a problem.

I have tried with the IMEX [ "IMEX=1;" tells the driver to always read "intermixed" data columns as text] but this kills the app and I can not find information on this....yet.

Anyone have an idea?

The code below works great for single data type in the whole file or data that can be cast to a string.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Private Sub loaddatagrid(ByVal myDataset As Object)
        Dim parentrow As DataRow
        Dim parenttable As DataTable

        parenttable = myDataset.Tables(0)
        Dim i As Integer = 0
        Me.dgPostField.DataSource = parenttable
        For Each parentrow In parenttable.Rows
            Application.DoEvents()
            If Trim(CType(dgPostField.Item(i, 2), String)) = "" Then
                dgPostField.Item(i, 3) = "n/a"
            End If
            dgPostField.Refresh()
            i = i + 1
        Next parentrow

    End Sub
~~~~~~~~~~~~~~~~~~~~~~~~~
Guy

Guy Buller
Project Module Leader
Geological
Survey of Canada
__________________
Guy
 
Old September 1st, 2004, 08:57 AM
Authorized User
 
Join Date: Aug 2004
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Ok I got this one figured out.

It was embarrassingly simple!

me.datagrid.datasource = dataset.tables(0).defaultview

Guy





Similar Threads
Thread Thread Starter Forum Replies Last Post
Determining Data type with CIN Bourne C++ Programming 2 March 23rd, 2007 05:40 PM
Converting excel data to Access using excel VBA ShaileshShinde VB Databases Basics 1 April 26th, 2006 07:57 AM
changing data type when importing Excel worksheet awwhite Access VBA 0 September 8th, 2004 09:37 AM
Determining DirectoryItem Type [email protected] VB.NET 0 June 3rd, 2004 05:30 PM
Data Type error but it is the correct type Mitch SQL Server 2000 2 March 19th, 2004 11:31 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.