6 Replies Latest reply: Sep 14, 2010 3:47 AM by Octopus Rex RSS

    OraDynaSet not returning the correct number of records.

    ChrisPeer1
      Hello All, I am writing VB code in Excel 2007 and retrieving records from a Oracle 9i database. When I run my query from TOAD or any other sql app I get 56 records returned for certain query. However, when I do it from VB in excel and write the values to the excel file, it will not return the last 3 records, any suggestions? Here is part of my code:

      Worksheets("Report").Range("A3").Value = ""
      Worksheets("Report").Range("B3").Value = "Period"
      Worksheets("Report").Range("C3").Value = "Budget"
      Worksheets("Report").Range("D3").Value = "Projected"

      strSQL = "select group_name,period_name,budget_value,budget_value project from nlas_bdgt_loading_stg where plant = " & plant & " and group_number = 1 order by group_number, period_num"

      Set OraDynaSet = objDataBase.DBCreateDynaset(strSQL, 0&)

      If OraDynaSet.RecordCount > 0 Then

      OraDynaSet.MoveFirst
      'Loop the recordset for returned rows
      For i = 4 To OraDynaSet.RecordCount
      'Put the results in columns
      ActiveSheet.Cells(i, 1) = OraDynaSet.Fields(0).Value
      ActiveSheet.Cells(i, 2) = OraDynaSet.Fields(1).Value
      ActiveSheet.Cells(i, 3) = OraDynaSet.Fields(2).Value
      ActiveSheet.Cells(i, 4) = OraDynaSet.Fields(3).Value
      OraDynaSet.MoveNext
      Next i
      End If

      Thanks,
      Chris