New topic: 

ADODB problem with Excel - column blank???

<http://forums.realsoftware.com/viewtopic.php?t=24010>

       Page 1 of 1
   [ 1 post ]                 Previous topic | Next topic         Author  
Message       MagicMatt           Post subject: ADODB problem with Excel - 
column blank???Posted: Wed Aug 20, 2008 8:36 am                        
Joined: Tue Aug 05, 2008 1:20 pm
Posts: 38              Code:Dim adodbConnection As New 
OleObject("ADODB.Connection")
Dim adodbCommand as new OLEObject( "ADODB.Command" )
Dim adodbRecordSet as OLEObject
Dim connectionString as string
Dim n as Integer

connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data 
Source=C:\Datafile.xls;Extended Properties=Excel 8.0;"

adodbConnection.Open( connectionString )

adodbCommand.ActiveConnection = adodbConnection

adodbCommand.CommandText = "SELECT * FROM [Sheet1$]"

adodbRecordSet = adodbCommand.Execute

While Not adodbRecordSet.EOF
  ListBox1.AddRow(adodbRecordSet.Fields(0).Value)
  For n=1 to 14
  If (adodbRecordSet.Fields(n).Value<>Nil) then
  Listbox1.Cell(Listbox1.LastIndex,n)=adodbRecordSet.Fields(n).Value
  End if
  next
  adodbRecordSet.MoveNext
Wend
adodbRecordSet.Close
adodbConnection.Close



Column 7 starts with some blank cells but further down in the spreadsheet there 
is data to be found (numbers in the range 0.01 to 0.9)
Column 7 is returning nil (null) all the time, for all the records. 

WTF? How does that happen??

I tried adding this just after the For...
Code:
if n=7 then
  If (adodbRecordSet.Fields(n).Value=Nil) then
  msgbox ("It's nil again! : " + adodbRecordSet.Fields(0).Value)
  end if
end if



It was called for every record, even ones that I know (by looking at the 
spreadsheet and comparing with the MsgBox) have data in column 7!

How do I diagnose this? It makes no sense to me!   
                            Top           Display posts from previous: All 
posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost 
timeSubject AscendingDescending          Page 1 of 1
   [ 1 post ]     

-- 
Over 900 classes with 18000 functions in one REALbasic plug-in. 
The Monkeybread Software Realbasic Plugin v8.1. 

&lt;http://www.monkeybreadsoftware.de/realbasic/plugins.shtml&gt;

[email protected]

Reply via email to