P
Paul
I have written a program that reads an excel spreadsheet
using oledb.
I am able to retrieve about 90% of each line. In some
cases I get null values for cells that should return text
information.
In the code below, the value returned by rs.Item(0) is a
System.DBNull, yet there is data in that column (1).
rs.Item(1) of the same row returns the expect data that
is in column 2.
I do not see any pattern related to formatting. These
are text strings without any special characters. There
may be "formatting" such as cell justification, font
size, bolding, etc.
Can anyone shed some light on why I am getting these null
values?
<Code>
strCn = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & OpenFileDialog1.FileNames(filenum)
& ";Extended Properties=""Excel8.0;HDR=NO;MAXSCANROWS=1"""
cn.ConnectionString = strCn
cn.Open()
objCmd.CommandText = "Select * from [new products$]"
objCmd.Connection = cn
Dim rs As OleDbDataReader = objCmd.ExecuteReader
For i = 1 To 4 ' skip lines
rs.Read()
Debug.Write(i.ToString & ", " & rs.Item(0) & "," &
rs.Item(1) & "," & rs.Item(2) & "," & rs.Item(3) & vbCrLf)
Next
using oledb.
I am able to retrieve about 90% of each line. In some
cases I get null values for cells that should return text
information.
In the code below, the value returned by rs.Item(0) is a
System.DBNull, yet there is data in that column (1).
rs.Item(1) of the same row returns the expect data that
is in column 2.
I do not see any pattern related to formatting. These
are text strings without any special characters. There
may be "formatting" such as cell justification, font
size, bolding, etc.
Can anyone shed some light on why I am getting these null
values?
<Code>
strCn = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & OpenFileDialog1.FileNames(filenum)
& ";Extended Properties=""Excel8.0;HDR=NO;MAXSCANROWS=1"""
cn.ConnectionString = strCn
cn.Open()
objCmd.CommandText = "Select * from [new products$]"
objCmd.Connection = cn
Dim rs As OleDbDataReader = objCmd.ExecuteReader
For i = 1 To 4 ' skip lines
rs.Read()
Debug.Write(i.ToString & ", " & rs.Item(0) & "," &
rs.Item(1) & "," & rs.Item(2) & "," & rs.Item(3) & vbCrLf)
Next