CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: Help Needed!

  1. #1
    Join Date
    May 2001
    Posts
    2

    Help Needed!

    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


  2. #2
    Join Date
    May 2001
    Posts
    2

    Re: Help Needed!

    Forgot one thing, Include Microsoft ActiveX Data Objects Recordset 2.5 Library from References for the above code to work

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


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured