Click to See Complete Forum and Search --> : Help Needed!


nkanakagiri
May 8th, 2001, 12:32 PM
Hi,

I am trying to update Excel Sheet using ADO.

Issue is, though I am trying to update one row at a time(using movefirst and movenext) it updates "all" the rows at each update!

Define a range in Excel called "plotdata" with 4 columns and six rows. Name the columns(A,B,C,D)and save the excel sheet as C:\ABC.XLS

Include Microsoft Excel Library from references and use the following code. The code should put 5 in the column ("C") of first row but it updates the column "C" of the whole table with 5.

Help!

Private Sub Form_Load()
Dim oExcelConn As ADODB.Connection
Dim oExcelRSData As ADODB.Recordset

Set oExcelConn = New ADODB.Connection
Set oExcelRSData = New ADODB.Recordset

oExcelConn.Open "driver={Microsoft Excel Driver (*.xls)};dbq=" & "C:\ABC.XLS" & ";ReadOnly=0;"

oExcelRSData.Open "select * from PlotData", oExcelConn, adOpenKeyset, adLockOptimistic
oExcelRSData.MoveFirst
oExcelRSData.Fields("C") = 5
oExcelRSData.Update
MsgBox "done"
End
End Sub

nkanakagiri
May 8th, 2001, 12:58 PM
Forgot one thing, Include Microsoft ActiveX Data Objects Recordset 2.5 Library from References for the above code to work

BTW HELP!!!!!!!!!!!!!!!!!