1 Reply Latest reply on Sep 14, 2004 7:30 PM by 82532

    Invalid bookmark in an unbound Sheridan grid with Oracle 9i

    428268
      Hi, we have an application that worked on Oracle 8i with oo4o and oraoldb.

      We use a Sheridan grid in unbound mode with the following code in the unboundReadData event where RecGlobal is an OraDynaset:

      Public Sub UnboundReadData(RowBuf As SSDataWidgets_B.ssRowBuffer, StartLocation As Variant, ReadPriorRows As Boolean)
      On Error GoTo ErrorGridStreetSectorUnboundReadData:

      Dim Rcnt, Rcount, Rcounter As Integer

      If Grid.Redraw = False Then Exit Sub
      If recGlobal Is Nothing Then Exit Sub
      If IsNull(StartLocation) Then
      If ReadPriorRows Then
      recGlobal.MoveLast
      Else
      recGlobal.MoveFirst
      End If
      Else
      'Conversion from HEX string to Binary string
      recGlobal.Bookmark = objMain.HexToBookmark(StartLocation)
      If ReadPriorRows Then
      recGlobal.MovePrevious
      Else
      recGlobal.MoveNext
      End If
      End If
      For Rcount = 0 To RowBuf.RowCount - 1
      If recGlobal.BOF Or recGlobal.EOF Then Exit For
      Select Case (RowBuf.ReadType)
      Case 0
      For Rcounter = 0 To RowBuf.ColumnCount - 1
      RowBuf.Value(Rcount, Rcounter) = recGlobal(Grid.Columns(Rcounter).Name).Value
      Next Rcounter
      RowBuf.Bookmark(Rcount) = objMain.BookmarkToHex(recGlobal.Bookmark)
      Case 1
      RowBuf.Bookmark(Rcount) = objMain.BookmarkToHex(recGlobal.Bookmark)
      Case 2
      RowBuf.Value(Rcount, Rcounter) = recGlobal(Grid.Columns(Rcounter).Name).Value 'recGlobal(Rcounter).Value
      RowBuf.Bookmark(Rcount) = objMain.BookmarkToHex(recGlobal.Bookmark)
      Case 3
      End Select

      If ReadPriorRows Then
      recGlobal.MovePrevious
      Else
      recGlobal.MoveNext
      End If
      Rcnt = Rcnt + 1
      Next Rcount
      RowBuf.RowCount = Rcnt

      ExitGridStreetSectorUnboundReadData:
      Exit Sub
      ErrorGridStreetSectorUnboundReadData:
      Dim ErrNum As Long, ErrDesc As String
      ErrNum = objMain.GetLastError(Err.Number)
      Select Case ErrNum
      Case 3021
      Case 40088: Grid.ReBind 'No open cursor
      Case 40022 'Resultset is empty
      Case Else
      ErrDesc = objMain.GetLastErrorDesc(Err.Description)
      MsgBox ErrNum & " : " & ErrDesc, CriticalFlag, Msg(1)
      End Select
      Resume ExitGridStreetSectorUnboundReadData:
      End Sub

      Here is the code for the HexToBookmark and BookmarkToHex functions we use:

      Private Function Mainfunctions_HexToBookmark(ByVal S As Variant) As Variant
      Dim I As Integer, STmp As Variant
      If IsNull(S) Then Exit Function
      For I = 1 To Len(S) Step 2
      STmp = STmp & Chr(Val("&h" & Mid(S, I, 2)))
      Next
      Mainfunctions_HexToBookmark = STmp
      End Function

      Private Function Mainfunctions_BookmarkToHex(ByVal S As Variant) As Variant
      Dim I As Integer, H As String, STmp As Variant
      For I = 1 To Len(S)
      H = Hex(Asc(Mid(S, I, 1)))
      If Len(H) = 1 Then H = "0" & H
      STmp = STmp & H
      Next
      Mainfunctions_BookmarkToHex = STmp
      End Function

      Now we need to make our application run on Oracle 9i (patchset 9204) (with oraoledb 9.2.0.4.0 and oo4o 9.2.0.4.8) and our Sheridan Grid in unbound mode seems to work fine, except that after some time I reexecute the query to refresh the grid I get an invalid bookmark error message (OIP.4121) and only 10 records from the recordset are displayed even if the recordcount is greater.

      Anything that can help solve this somehow weird problem is welcome.
      Thanks