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
|