I tried a couple of things such as dr(dc.ColumnName.ToString) and CSTR(dr(dc.ColumnName)) but neither work. what do I need to do?
I am currently trying to get the data type but no luck.
Error message on line in red below:
An unhandled exception of type 'System.ArgumentException' occurred in mscorlib.dll
Additional information: Method's type signature is not Interop compatible.
the column is a "TimeSpan" datatype whenits in VB.NET and in SQL its "TIME" datatype. Changing it is not an option.
--
TIA
DougP
I am currently trying to get the data type but no luck.
Error message on line in red below:
An unhandled exception of type 'System.ArgumentException' occurred in mscorlib.dll
Additional information: Method's type signature is not Interop compatible.
the column is a "TimeSpan" datatype whenits in VB.NET and in SQL its "TIME" datatype. Changing it is not an option.
--
Code:
Dim oXL As Excel.Application = CType(CreateObject("Excel.Application"), Excel.Application)
Dim oWB As Excel.Workbook
Dim oSheet As Excel.Worksheet
Dim oRng As Excel.Range
oXL.Visible = True
oWB = oXL.Workbooks.Add
oSheet = CType(oWB.ActiveSheet, Excel.Worksheet)
Dim dc As DataColumn
Dim dr As DataRow
Dim CellData As String
' Dim dt As DataTable
Dim colIndex As Integer = 0
Dim rowIndex As Integer = 0
For Each dc In dt.Columns
colIndex = colIndex + 1
oXL.Cells(1, colIndex) = dc.ColumnName
Next
For Each dr In dt.Rows
rowIndex = rowIndex + 1
colIndex = 0
For Each dc In dt.Columns
colIndex = colIndex + 1
If IsDBNull(dr(dc.ColumnName)) Then
'do nothing
Else
'Select Case dr(dc.ColumnName.GetTypeCode)
' Case "Chars"
'End Select
oXL.Cells(rowIndex + 1, colIndex) = [COLOR=red]dr(dc.ColumnName)[/color] '<<<<<<<<<<< error here
End If
Next
Next
TIA
DougP