Record Set Issues Help

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mama123
    New Member
    • Mar 2007
    • 3

    #1

    Record Set Issues Help

    This is a part of my code in VB:

    .
    .
    Code:
    Dim rsora1 As ADODB.Recordset
    .
    .
    Set cnOra = New ADODB.Connection
    .
    .
    Set rsora1 = New ADODB.Recordset
    .
    .
    rsora1.CursorLocation = adUseServer
    .
    .
    If Worksheets.Item("sheet1").Cells(j + b, i).Value <> rsora1![val_arr] Then
    i want to compare the value in a cell in excel to the value in the resultset. the problem is that <val_arr> in rsora1![ ] is a array variable(of type string), ie, a(i-3)=val_arr. How do i go about it???
    Last edited by willakawill; Mar 14 '07, 03:46 PM. Reason: please use [code]...[/code] tags when posting code
  • willakawill
    Top Contributor
    • Oct 2006
    • 1646

    #2
    Hi. In the code you have posted, rsora1 has not been populated with any values. Could you post the code where val_arr is declared and assigned a value?

    Comment

    • mama123
      New Member
      • Mar 2007
      • 3

      #3
      Originally posted by willakawill
      Hi. In the code you have posted, rsora1 has not been populated with any values. Could you post the code where val_arr is declared and assigned a value?
      here i populate rsora1:
      rsora1.Open "select rowid,CUSTOMER_ ID,ITEM_NO,ITEM _DESCRIPTION,BE GIN_DATE,END_DA TE from XXITEM_MAP_TABL E where CUSTOMER_NO = " & cust_no, cnOra, adOpenForwardOn ly (cust_no is a variable containing a value)

      these are the array values:
      a(0) = "CUSTOMER_I D"
      a(1) = "ITEM_NO"
      a(2) = "ITEM_DESCRIPTI ON"
      a(3) = "BEGIN_DATE "
      a(4) = "END_DATE"

      i use a loop to get the specific value from the array:
      For i = 3 To 13 Step 2
      val_arr = a((i - 3) / 2)

      now i do this:
      If Worksheets.Item ("sheet1").Cell s(j + b, i).Value <> rsora1![val_arr] Then.....
      but i can't get rsora1![val_arr] to point to a particular value in the resultset.
      help me!!

      Comment

      • willakawill
        Top Contributor
        • Oct 2006
        • 1646

        #4
        The syntax for ado is:
        Code:
        rsora1(val_arr)
        I have never used a variable here and I recommend that you don't either. It is far easier for you to use this syntax:
        Code:
        rsora1((i - 3) / 2)
        The result of this loop:
        Code:
        For i = 3 To 13 Step 2
        val_arr = a((i - 3) / 2)
        Is that val_arr always ends the loop as a(5) and there is no a(5)

        Comment

        • mama123
          New Member
          • Mar 2007
          • 3

          #5
          Originally posted by willakawill
          The syntax for ado is:
          Code:
          rsora1(val_arr)
          I have never used a variable here and I recommend that you don't either. It is far easier for you to use this syntax:
          Code:
          rsora1((i - 3) / 2)
          The result of this loop:
          Code:
          For i = 3 To 13 Step 2
          val_arr = a((i - 3) / 2)
          Is that val_arr always ends the loop as a(5) and there is no a(5)
          problem solved
          thanx a million

          Comment

          • willakawill
            Top Contributor
            • Oct 2006
            • 1646

            #6
            Originally posted by mama123
            problem solved
            thanx a million
            You are very welcome

            Comment

            Working...