Hallo everybody,
after I have converted my database tables from HSQLDB to Firebird I found a strange behaviour with recordsets.
After executing a query I need the number of records in the recordset. As there was / is(?) no recordCount property I use the following code:
Function getRecordCount(objResult As Object) As Long
Dim intCount As Long
' initialize Count
intCount = 0
' iterate over resultset
While objResult.Next()
' increment Count
intCount = intCount + 1
Wend
' Reposition the cursor
objResult.First()
' Return RecordCount
getRecordCount = intCount
End Function
When I reposition the cursor with objResult.First() an error occurs ‘first not supported in firebird’. If I comment out the while loop everything is executed without an error. That seems to mean that the resultset is FORWARD_ONLY - but it is in fact declared like this:
Function getResultSet(objDbCon As Object, strSql As String) As Object
Dim objStatement As Object
Dim objResult As Object
' Statement erstellen
objStatement = objDbCon.createStatement()
objStatement.ResultSetConcurrency = _
com.sun.star.sdbc.ResultSetConcurrency.UPDATABLE
objStatement.ResultSetType = _
com.sun.star.sdbc.ResultSetType.SCROLL_SENSITIVE
' Abfrage ausfuehren
objResult = objStatement.executeQuery(strSql)
' ResultSet zurückgeben
getResultSet = objResult
End Function
In the HSQLDB-Verion everything works as it should - could it be reultsets are declared FORWARD_ONLY regardles what you state?