View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
MarkS[_3_] MarkS[_3_] is offline
external usenet poster
 
Posts: 1
Default Moving data from SQL Server to Excel

Hi,
I use this code to get the data from a SQL Server database and put it into a
spread sheet

' Get Geneneration Data
sSql = "Select Date,hh,Dartm1,Eildon1,Eildon2 from mdff_Generation_Xtab"
& _
" Where Date ='20051023' And Date < '20051030' Order By Date,hh"
rsADO.Open sSql, connMelbourne, adOpenStatic, adLockReadOnly

' Copy Data
rsADO.MoveFirst
Counter = 2
Do Until rsADO.EOF
Range("A" & Counter).Value = rsADO!Date
Range("B" & Counter).Value = rsADO!hh
Range("C" & Counter).Value = rsADO!Dartm1
Range("D" & Counter).Value = rsADO!Eildon1
Range("E" & Counter).Value = rsADO!Eildon2
Counter = Counter + 1
rsADO.MoveNext
Loop

I think there is a way of going straight to the spread sheet without going
through the load the record set copy to spread sheet route.

Any suggestions of a better way that does not involve so much work, there
are a lot of these to do?

Thanks MarkS