Skip to content
4 changes: 3 additions & 1 deletion src/Runtime/XSharp.Core/State/EnumSet.prg
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
USING XSharp
USING XSharp.RDD.Enums
USING System.Collections.Generic
NAMESPACE XSharp
BEGIN NAMESPACE XSharp

/// <include file="XSharp.Core.Docs.xml" path="doc/Set/*" />
ENUM Set
Expand Down Expand Up @@ -431,6 +431,8 @@ ENUM Set

END ENUM

END NAMESPACE

#region Defines
/// <include file="XSharp.CoreDefines.xml" path="members/Set.Exact/*" />
/// <include file="CoreComments.xml" path="Comments/Set/*" />
Expand Down
2 changes: 1 addition & 1 deletion src/Runtime/XSharp.RT/RDD/Db.prg
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ FUNCTION DbRecordInfo(kInfoType, uRecId, uNewValue) AS USUAL CLIPPER
FUNCTION DbRLock(uRecId) AS USUAL CLIPPER
RETURN VoDb.RLock(uRecId)

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/flock/*" />
/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/dbrlock/*" />
FUNCTION DbFlock() AS USUAL CLIPPER
RETURN VoDb.Flock()

Expand Down
2 changes: 1 addition & 1 deletion src/Runtime/XSharp.SQLRdd/Metadata/Database.prg
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@ end class
var rdr := (DbDataReader) oPar
var pos := SELF:GetPos(rdr, nReason:ToString())
if pos >= 0
var num := rdr:GetDecimal(pos)
var num := rdr:GetValue(pos)
return Convert.ToInt32(num)
endif
catch
Expand Down
7 changes: 5 additions & 2 deletions src/Runtime/XSharp.SQLRdd/RDD/SQLRDD-Main.prg
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,7 @@ partial class SQLRDD inherit Workarea
self:DataTable:RejectChanges()
endif
_updatedRows:Clear()
// TODO: thomas optimize. Change reccount when adding or deleting a row above instead of reloading data from DB with _GetRecCount
self:_GetRecCount()
endif
return lOk
Expand Down Expand Up @@ -641,8 +642,10 @@ partial class SQLRDD inherit Workarea
OVERRIDE METHOD GoToId(oRec AS OBJECT) AS LOGIC
LOCAL result AS LOGIC
TRY
VAR nRec := Convert.ToUInt32( oRec )
result := SELF:GoTo( (DWORD) nRec )
VAR nRec := Convert.ToUInt32( oRec )
if nRec != RowNumber
result := SELF:GoTo( (DWORD) nRec )
endif
CATCH ex AS Exception
SELF:_dbfError(ex, Subcodes.EDB_GOTO,Gencode.EG_DATATYPE, "SQLRDD.GoToId",FALSE)
result := FALSE
Expand Down
25 changes: 15 additions & 10 deletions src/Runtime/XSharp.SQLRdd/RDD/SQLRDD-Private.prg
Original file line number Diff line number Diff line change
Expand Up @@ -601,16 +601,20 @@ partial class SQLRDD
return result

PRIVATE METHOD _GotoRecord(nRec as DWORD) AS LOGIC
// Brute walk
SELF:_command:CommandText := _builder:BuildRowNumberStatement(nRec)
var result := SELF:_command:ExecuteScalar(SELF:_oTd:Name)
var iResult := Convert.ToInt64(result)
// shouldn't this be ToUInt32?

// determine correct page
SELF:_currentPageNo := (INT) ((iResult - 1) / SELF:_oTd:PageSize) + 1
SELF:_ClearTable()
SELF:DataTable := SELF:_ReadTable("")

if SELF:DataTable:Rows:Count < 1
// Brute walk
SELF:_command:CommandText := _builder:BuildRowNumberStatement(nRec)
var result := SELF:_command:ExecuteScalar(SELF:_oTd:Name)
var iResult := Convert.ToInt64(result)
// shouldn't this be ToUInt32?

// determine correct page
SELF:_currentPageNo := (INT) ((iResult - 1) / SELF:_oTd:PageSize) + 1
SELF:_ClearTable()
SELF:DataTable := SELF:_ReadTable("")
end if

// locate the row in the page
SELF:RowNumber := 1
DO WHILE SELF:RowNumber <= SELF:DataTable:Rows:Count
Expand All @@ -620,6 +624,7 @@ partial class SQLRDD
SELF:RowNumber+= 1
ENDDO
RETURN FALSE

PRIVATE METHOD _GotoRow(nRow as LONG) AS LOGIC
SELF:_Found := FALSE
var nCount := SELF:DataTable:Rows:Count
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,9 @@ internal class SqlDbTableCommandBuilder
cOrderby := Functions.List2String(CurrentOrder:OrderList)
if SELF:_oTable:HasRecnoColumn
if ! String.IsNullOrEmpty(cOrderby)
cOrderby := cOrderby + ", " + Provider:QuoteIdentifier(self:_oTable:RecnoColumn)
if !cOrderby.Contains(Provider:QuoteIdentifier(self:_oTable:RecnoColumn))
cOrderby := cOrderby + ", " + Provider:QuoteIdentifier(self:_oTable:RecnoColumn)
endif
else
cOrderby := Provider:QuoteIdentifier(self:_oTable:RecnoColumn)
endif
Expand Down
4 changes: 1 addition & 3 deletions src/Tests/SqlRDDTests/Program.prg
Original file line number Diff line number Diff line change
Expand Up @@ -597,8 +597,6 @@ FUNCTION EventHandler(oSender AS Object, e AS XSharp.RDD.SqlRDD.SqlRddEventArgs)
case "Index:Customers"
e:Value := "PK,CompanyName,ContactName,Address"
end switch
case SqlRDDEventReason.SeekReturnsSubset
e:Value := TRUE
end switch
if showEvents
? "Event", e:Name, e:Reason:ToString(), e:Value
Expand Down Expand Up @@ -889,7 +887,7 @@ FUNCTION TestGsTutor() AS VOID

System.Console.ReadLine()

// UBLIC VIRTUAL METHOD RecordInfo(kRecInfoType, nRecordNumber, uRecVal) AS USUAL CLIPPER
// PUBLIC VIRTUAL METHOD RecordInfo(kRecInfoType, nRecordNumber, uRecVal) AS USUAL CLIPPER
//var test := DbRecordInfo(DBRI_LOCKED, 3)

// DbRLock(4)
Expand Down